help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Error: subscript indices must be either positive integers or logical


From: indium
Subject: Re: Error: subscript indices must be either positive integers or logicals - For simple surf plot
Date: Fri, 25 Nov 2011 18:03:25 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Thu, Nov 24, 2011 at 01:33:27PM -0800, jammydav93 wrote:
> Hi,
> 
> I'm trying to make a function which plots the values of C from A and B
> 
> My function is simply:
> 
> 
> 
> function f(g)
> 
> for a=0:pi
>       for b=0:pi
>       
> c(a,b)=tan(g*a) * arcsin(g*b);
> 
>       end
> end
> 
> surf(c);
> 
> 
> The function works when I start the loops from 1, however I need the loops
> to start at 0, when I start the loops at 0 I get the error "subscript
> indices must be either positive integers or logicals."
> 
> Anybody know how I can solve this?
> 
> Thanks
> 
> L
> 
> --
> View this message in context: 
> http://octave.1599824.n4.nabble.com/Error-subscript-indices-must-be-either-positive-integers-or-logicals-For-simple-surf-plot-tp4105648p4105648.html
> Sent from the Octave - General mailing list archive at Nabble.com.
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave


Please realize that a=0:pi will give a the values {0,1,2,3} and so
there is not 3.1415... = pi value ever assigned to 'a'. In your case you
could as well run over a=0:3 .

As the error message said: you are using 'a' as a index value of a
matrix or a vector.  Those index values always start at 1, not 0.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]