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: "Index must be a positive integer or logical"
Replies: 1   Last Post: Feb 8, 2013 5:12 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Jos

Posts: 1,266
Registered: 10/24/08
Re: "Index must be a positive integer or logical"
Posted: Feb 8, 2013 5:12 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Kevin " <kmong92@hotmail.com> wrote in message <kf1s4k$8qh$1@newscl01ah.mathworks.com>...
> Hi,
>
> I'm trying to plot a rect function under the requirement that
> w(n) = {1 when (-M) <= n <= M , else 0}
>
> M=25;
> w = size(101);
> j=1;
>
> for n= -50:1:50;
>
> if (-M)<= n && n <= M
> w(j) = 1;
> else
> w(j) = 0;
> end
> j=j+1;
> end
>
> plot(w(j))
>
> M=25
>
> This works, except the plot is obviously from 25 - 25 and doesn't demonstrate w(n) but w(j)... is there a way to shift?.... or suggestions?


Pass all the elements of w, and add specific x-coordinates:
plot(-50:50, w)

help plot
could've helped you ...

~ Jos



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.