Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: ()-indexing must appear last in an index expression.
Replies: 2   Last Post: Mar 13, 2013 9:27 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Christopher Creutzig

Posts: 264
Registered: 2/24/09
Re: ()-indexing must appear last in an index expression.
Posted: Mar 13, 2013 9:27 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.