[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: help how do I multiply a scalar by a cell (element) and store in a s
From: |
Jerry Baucum |
Subject: |
Re: help how do I multiply a scalar by a cell (element) and store in a scalar |
Date: |
Sun, 9 Sep 2012 17:10:57 -0500 |
Thanks, I finally notice I was using {} instead of []
On Sun, Sep 9, 2012 at 4:04 PM, Max Brister <address@hidden> wrote:
> On Sun, Sep 9, 2012 at 2:59 PM, Jordi GutiƩrrez Hermoso
> <address@hidden> wrote:
>> On 9 September 2012 16:37, Jerry Baucum <address@hidden> wrote:
>>> Sample =
>>> {
>>> [1,1] = -0.12300
>>> [1,2] = 0.23400
>>> }
>>>
>>> value = pi * Sample(1,2)
>>>
>>> I'm running up against the error
>>>
>>> error: binary operator `*' not implemented for `scalar' by `cell' operations
>>
>> Do you really want a cell array and not a matrix?
>>
>> If so, do
>>
>> cellfun(@times, c, {5}, 'Unif', false)
>>
>> Otherwise, use matrices:
>>
>> Sample = [0.12; 0.34];
>> 5*Sample
>>
>> HTH,
>> - Jordi G. H.
>
> Alternatively, you can use curly braces for indexing. From you original
> example,
>
> Sample =
> {
> [1,1] = -0.12300
> [1,2] = 0.23400
> }
> value = pi * Sample{1, 2}
>
> As Jordi suggested, matrices are a better option if your Sample array
> is uniformly real.
>
> --
> Max Brister
--
Jerry