octave-maintainers
[Top][All Lists]
Advanced

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

Re: Assignment through repeated indexing on LHS


From: Avinoam
Subject: Re: Assignment through repeated indexing on LHS
Date: Fri, 20 Oct 2017 01:57:04 -0700 (MST)

Philip Nienhuis wrote
> (Couldn't find it in the manual or on the web)
> I wonder if the following is a legal construct:
> 
> cell_array(:, 3:5)(index-vector) = some_value
> 
> or with a real example (invoking the testc cell array in  attached
> testc.mat
> <http://octave.1599824.n4.nabble.com/file/t131602/testc.mat>  ) I
> tried:
> 
> load testc.mat
> idx = find (cellfun (@isempty, testc(:, 3:8)));
> testc(:, 3:8)(idx) = NaN
> 
> ...yielding the following somewhat incomprehensible (to me) error message:
> error: () must be followed by . or close the index chain
> 
> Am I correct to conclude that repeated indexing on the LHS of an
> expression
> is illegal, or at least unsupported?
> In that case I think the error message could be more clear, like
> explicitly
> mentioning that repeated indexing on LHS is not permitted.
> 
> Typing:
> testc(:, 3:8)(idx)
> works fine of course as it is essentially a RHS expression.
> 
> Thanks,
> 
> Philip
> 
> 
> 
> --
> Sent from:
> http://octave.1599824.n4.nabble.com/Octave-Maintainers-f1638794.html


testc (find (cellfun (@isempty, testc))) = {NaN}

also works, though it's not exactly what you want.

Avinoam 



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-Maintainers-f1638794.html



reply via email to

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