|
|
Re: ()-indexing must appear last in an index expression.
Posted:
Mar 13, 2013 9:27 AM
|
|
On 11.03.13 14:22, Natali wrote: > It is a silly error but I don't know how to write it better. I have 6 signals i want to calculate what it goes after: > > %% Adjusting frequency range to Nyquist frequency > > n=[n1,n2,n3,n4,n5,n6]; % Each stands for the number of samples of each signal > f=[f1,f2,f3,f4,f5,f6]; % The frequency of each of them > Yamp=[Yamp1,Yamp2,Yamp3,Yamp4,Yamp5,Yamp6]; % And the amplitude also. > for m=1:6 > if mod(n,2)==0
Should probably read n(m), not n, right?
> n_cutoff(m)=n(m)./2 % Even: takes the first half of the frequency range > else > n_cutoff(m)=(n(m)-1)./2 % Odd: takes the first half of the frequency range (rounded down) > end
Also note that you could simply use n_cutoff(m)=floor(n(m)./2) instead of the if branching.
> f(m)=f(m)(0:n_cutoff(m)); % Scales down the frequency range
As Steven already told you, MATLAB doesn't allow that, syntactically. Try two steps instead:
fm = f(m); f(m) = fm(0:n_cutoff(m));
And similarly for the lines below.
HTH, Christopher
|
|