help-octave
[Top][All Lists]
Advanced

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

Re: help on assignment in struct arrays


From: Jaroslav Hajek
Subject: Re: help on assignment in struct arrays
Date: Fri, 10 Sep 2010 14:01:25 +0200

On Fri, Sep 10, 2010 at 1:56 PM, Eric Chassande-Mottin
<address@hidden> wrote:
>
>
> hi,
>
> I'd like to replace all occurence of "~" by NaN in a struct array.
> here is an example:
>
>> a(1).a=1; a(1).b=2; a(2).a="~"; a(2).b=3; a(3).a="~"; a(3).b=4;
>> idx=find([a.a]=="~")
> idx =
>
>   2   3
>
> I'm able to find the "~" but don't know how to do the assignment:
>> [a(idx).a]=nan
> error: some elements undefined in return list

Please read the section in the manual about comma separated lists,
then you'll probably understand what's wrong and why the error
message. The correct way is
[a(idx).a] = deal (nan);


-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



reply via email to

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