help-octave
[Top][All Lists]
Advanced

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

Re: vectorisation and cell arrays


From: Ben Abbott
Subject: Re: vectorisation and cell arrays
Date: Fri, 27 Mar 2009 07:36:57 -0400


On Mar 27, 2009, at 7:32 AM, Bertrand Roessli wrote:

Hello,

Does anybody know if it is possible to vectorize
matrix operations (the matrices are stored in a cell array)
on a vector and so to avoid looping over the elements
of the cell? Thanks in advance

For example

a =

{
 [1,1] =

    1   0   0
    0  -1   0
    0   0   1

 [1,2] =

    1   0   0
   -1   0   0
    0   0  -1

e=[1;2;3];

a{1}*e

ans =

  1
 -1
 -3
works fine, but
a{:}*e

error: binary operator `*' not implemented for `cs-list' by `matrix'
operations

Take a look at cellfun

        help cellfun

        doc cellfun

Ben




reply via email to

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