From: adrianomeis03 on 26 Apr 2010 13:38 hello, I use matlab 4.2. I am an italian student. I am beginning to use matlab. I have written this code: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear NA=16; SA_delta_dp_vet=zeros(NA/8,1); sA_delta_dp_vet=[1 0]; for k=2:2:(NA/4) SA_delta_dp_vet(k)=0; for n=1:2:(NA/4-1) SA_delta_dp_vet(k/2)=SA_delta_dp_vet(k/2)+sA_delta_dp_vet((n+1)/ 2)*sin(2*pi*n*k/NA); end; end; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% I obtain: SA_delta_dp_vet =[0.707 1.0000 0 0] I have declared SA_delta_dp_vet with 2 cells. Before the loop starts, SA_delta_dp_vet still has 2 cells. Why has SA_delta_dp_vet 4 cells after the loop? What is it wrong in the code? Thanks, adriano meis
From: someone on 26 Apr 2010 13:50 "adrianomeis03(a)gmail.com" <adrianomeis03(a)gmail.com> wrote in message <22a46a4c-ba84-48a8-9d63-347de6a0b7d1(a)b23g2000yqn.googlegroups.com>... > > hello, > > I use matlab 4.2. > I am an italian student. > I am beginning to use matlab. > I have written this code: > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > > clear > > NA=16; > > SA_delta_dp_vet=zeros(NA/8,1); > > sA_delta_dp_vet=[1 0]; > > for k=2:2:(NA/4) > SA_delta_dp_vet(k)=0; > for n=1:2:(NA/4-1) > SA_delta_dp_vet(k/2)=SA_delta_dp_vet(k/2)+sA_delta_dp_vet((n+1)/ > 2)*sin(2*pi*n*k/NA); > end; > end; > > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > > > I obtain: > > SA_delta_dp_vet =[0.707 1.0000 0 0] > > > I have declared SA_delta_dp_vet with 2 cells. > Before the loop starts, SA_delta_dp_vet still has 2 cells. > Why has SA_delta_dp_vet 4 cells after the loop? > > What is it wrong in the code? > > Thanks, > > adriano meis > If you look at your for loop you have: > for k=2:2:(NA/4) > SA_delta_dp_vet(k)=0; So k = 2:2:4 and on the last iteration, SA_delta_dp_vet(4)=0; Perhaps you mean: > for k=2:2:(NA/4) > SA_delta_dp_vet(k/2)=0;
From: adrianomeis03 on 26 Apr 2010 15:14 On 26 Apr, 19:50, "someone" <some...(a)somewhere.net> wrote: > Perhaps you mean: > > > for k=2:2:(NA/4) > > SA_delta_dp_vet(k/2)=0; ok, thanks, adriano
|
Pages: 1 Prev: RS 232 to MATLAB Problem Next: Output Pulses from MEX-File to Digital Output |