Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


Jos
Posts:
1,268
Registered:
10/24/08


Re: "Index must be a positive integer or logical"
Posted:
Feb 8, 2013 5:12 AM


"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 xcoordinates: plot(50:50, w)
help plot could've helped you ...
~ Jos



