help-octave
[Top][All Lists]
Advanced

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

Re: parse error when accessing meshgrid elements


From: c.
Subject: Re: parse error when accessing meshgrid elements
Date: Tue, 24 Jun 2014 17:29:20 +0200

On 24 Jun 2014, at 13:46, rcharan51 <address@hidden> wrote:

> fine (after following c.-2 advise i moved the dot)now there is no error with
> the code but i have a problem with getz() function
> 
> when i execute getz(xx) it returns only one value (but xx is a matrix)

that is because getz is implemented assuming its input to be a scalar
and always returns a scalar.

if you want getz to be extended to work for array input you may want to contact 
the author and ask him/her about it.

> what should i do if i want  a value for every corresponding value of xx when
> operated by getz()

if you can't convince the author to modify getz.m for you and you are not able
to that yourself, your only option is to compute getz(xx) with a loop over
all elements:

yy = zeros (size (xx));
for ii = 1:numel (xx)
 yy(ii) = getz (xx(ii));
endfor

note that this may become very slow if xx is large.
using arrayfun instead of the for loop may be marginally faster.

c.





reply via email to

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