help-octave
[Top][All Lists]
Advanced

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

Re: cell array operations


From: c.
Subject: Re: cell array operations
Date: Thu, 16 Sep 2010 18:17:23 +0200


On 16 Sep 2010, at 16:18, dirac wrote:


Hi again everyone,

I have a quick question about cell arrays: I have a [20x1] cell array that
contains unequal length vectors in each element. How do I subtract a
constant from all of the elements in the cell arrays?

I can't think of a way to do it other than use for loops, which I'm told you
should always avoid!

Thanks in advance
MA

well, not sure whether its the best solution but you can do:

a ={[1 2 3]; [2 3]; [4 5 6 7 8]};
b = cellfun (@(x) x + 2, a, 'uniformoutput', false)

c.




reply via email to

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