binary operators not implemented for 'cell' by 'scalar' operations

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

binary operators not implemented for 'cell' by 'scalar' operations

Jonathan Camilleri
I thought I could do matrix multiplications and the mathematical operators, but evidently I cannot.

See


 m1 = {1 1; 2 4; 4 8; 3 6}
m1 =
{
  [1,1] =  1
  [2,1] =  2
  [3,1] =  4
  [4,1] =  3
  [1,2] =  1
  [2,2] =  4
  [3,2] =  8
  [4,2] =  6
}
>> m2 = m1.*0.2
error: binary operator '.*' not implemented for 'cell' by 'scalar' operations
>> m2 = m1^0.2
error: binary operator '^' not implemented for 'cell' by 'scalar' operations

--
Jonathan Camilleri

Mobile (MT): ++356 7982 7113
E-mail: [hidden email]
Please consider your environmental responsibility before printing this e-mail.
 
I usually reply to emails within 2 business days.  If it's urgent, give me a call.


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: binary operators not implemented for 'cell' by 'scalar' operations

marco atzeri-2


On 24/11/2015 09:56, Jonathan Camilleri wrote:

> I thought I could do matrix multiplications and the mathematical
> operators, but evidently I cannot.
>
> See
> https://en.wikipedia.org/wiki/Operation_(mathematics)
> https://en.wikipedia.org/wiki/Algebra
> https://en.wikipedia.org/wiki/Order_of_operations
>
>
>   m1 = {1 1; 2 4; 4 8; 3 6}
> m1 =
> {
>    [1,1] =  1
>    [2,1] =  2
>    [3,1] =  4
>    [4,1] =  3
>    [1,2] =  1
>    [2,2] =  4
>    [3,2] =  8
>    [4,2] =  6
> }
 >  >> m2 = m1.*0.2
 > error: binary operator '.*' not implemented for 'cell' by 'scalar'

m1 is not a Matrix.

May be you were looking for

octave:1> m1 = [1 1; 2 4; 4 8; 3 6]
m1 =

    1   1
    2   4
    4   8
    3   6

octave:2> m2 = m1.*0.2
m2 =

    0.20000   0.20000
    0.40000   0.80000
    0.80000   1.60000
    0.60000   1.20000




_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: binary operators not implemented for 'cell' by 'scalar' operations

Jonathan Camilleri
I tried this:

Read http://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

>> m1 = {1 1; 2 4; 4 8; 3 6}
m1 =
{
  [1,1] =  1
  [2,1] =  2
  [3,1] =  4
  [4,1] =  3
  [1,2] =  1
  [2,2] =  4
  [3,2] =  8
  [4,2] =  6
}
>> m2 = m1.^0.2
error: binary operator '.^' not implemented for 'cell' by 'scalar' operations
>> cell2mat(m2)
error: 'm2' undefined near line 1 column 10
error: evaluating argument list element number 1
>>

On 24 November 2015 at 10:00, Marco Atzeri <[hidden email]> wrote:


On 24/11/2015 09:56, Jonathan Camilleri wrote:
I thought I could do matrix multiplications and the mathematical
operators, but evidently I cannot.

See
https://en.wikipedia.org/wiki/Operation_(mathematics)
https://en.wikipedia.org/wiki/Algebra
https://en.wikipedia.org/wiki/Order_of_operations


  m1 = {1 1; 2 4; 4 8; 3 6}
m1 =
{
   [1,1] =  1
   [2,1] =  2
   [3,1] =  4
   [4,1] =  3
   [1,2] =  1
   [2,2] =  4
   [3,2] =  8
   [4,2] =  6
}
>  >> m2 = m1.*0.2
> error: binary operator '.*' not implemented for 'cell' by 'scalar'

m1 is not a Matrix.

May be you were looking for

octave:1> m1 = [1 1; 2 4; 4 8; 3 6]
m1 =

   1   1
   2   4
   4   8
   3   6

octave:2> m2 = m1.*0.2
m2 =

   0.20000   0.20000
   0.40000   0.80000
   0.80000   1.60000
   0.60000   1.20000




_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave



--
Jonathan Camilleri

Mobile (MT): ++356 7982 7113
E-mail: [hidden email]
Please consider your environmental responsibility before printing this e-mail.
 
I usually reply to emails within 2 business days.  If it's urgent, give me a call.

and, angel start-up investment opportunities available at http://slyth3.wix.com/jon-business.
Online resume is available online at http://mt.linkedin.com/in/jonathancamilleri and shared bookmarks at https://delicious.com/jon80.


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: binary operators not implemented for 'cell' by 'scalar' operations

karl
Am 24.11.2015 um 10:03 schrieb Jonathan Camilleri:
I tried this:

Read http://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

>> m1 = {1 1; 2 4; 4 8; 3 6}
m1 =
{
  [1,1] =  1
  [2,1] =  2
  [3,1] =  4
  [4,1] =  3
  [1,2] =  1
  [2,2] =  4
  [3,2] =  8
  [4,2] =  6
}
>> m2 = m1.^0.2
error: binary operator '.^' not implemented for 'cell' by 'scalar' operations
>> cell2mat(m2)
error: 'm2' undefined near line 1 column 10
error: evaluating argument list element number 1
>>

On 24 November 2015 at 10:00, Marco Atzeri <[hidden email]> wrote:


On 24/11/2015 09:56, Jonathan Camilleri wrote:
I thought I could do matrix multiplications and the mathematical
operators, but evidently I cannot.

See
https://en.wikipedia.org/wiki/Operation_(mathematics)
https://en.wikipedia.org/wiki/Algebra
https://en.wikipedia.org/wiki/Order_of_operations


  m1 = {1 1; 2 4; 4 8; 3 6}
m1 =
{
   [1,1] =  1
   [2,1] =  2
   [3,1] =  4
   [4,1] =  3
   [1,2] =  1
   [2,2] =  4
   [3,2] =  8
   [4,2] =  6
}
>  >> m2 = m1.*0.2
> error: binary operator '.*' not implemented for 'cell' by 'scalar'

m1 is not a Matrix.

May be you were looking for

octave:1> m1 = [1 1; 2 4; 4 8; 3 6]
m1 =

   1   1
   2   4
   4   8
   3   6

octave:2> m2 = m1.*0.2
m2 =

   0.20000   0.20000
   0.40000   0.80000
   0.80000   1.60000
   0.60000   1.20000




_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave



--
Jonathan Camilleri

Mobile (MT): ++356 7982 7113
E-mail: [hidden email]
Please consider your environmental responsibility before printing this e-mail.
 
I usually reply to emails within 2 business days.  If it's urgent, give me a call.

and, angel start-up investment opportunities available at http://slyth3.wix.com/jon-business.
Online resume is available online at http://mt.linkedin.com/in/jonathancamilleri and shared bookmarks at https://delicious.com/jon80.



_______________________________________________
Help-octave mailing list
Help -[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave

{1 1; 2 4; 4 8; 3 6} is not the same as [1 1; 2 4; 4 8; 3 6]. For the difference see the Octave manual "cell array" and "matrix".

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: binary operators not implemented for 'cell' by 'scalar' operations

Jonathan Camilleri
This would mean that it is not yet possible to plot contents of a cell but those of a matrix, this is just something that confused me.

On 24 November 2015 at 10:13, karl <[hidden email]> wrote:
Am 24.11.2015 um 10:03 schrieb Jonathan Camilleri:
I tried this:

Read http://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

>> m1 = {1 1; 2 4; 4 8; 3 6}
m1 =
{
  [1,1] =  1
  [2,1] =  2
  [3,1] =  4
  [4,1] =  3
  [1,2] =  1
  [2,2] =  4
  [3,2] =  8
  [4,2] =  6
}
>> m2 = m1.^0.2
error: binary operator '.^' not implemented for 'cell' by 'scalar' operations
>> cell2mat(m2)
error: 'm2' undefined near line 1 column 10
error: evaluating argument list element number 1
>>

On 24 November 2015 at 10:00, Marco Atzeri <[hidden email]> wrote:


On 24/11/2015 09:56, Jonathan Camilleri wrote:
I thought I could do matrix multiplications and the mathematical
operators, but evidently I cannot.

See
https://en.wikipedia.org/wiki/Operation_(mathematics)
https://en.wikipedia.org/wiki/Algebra
https://en.wikipedia.org/wiki/Order_of_operations


  m1 = {1 1; 2 4; 4 8; 3 6}
m1 =
{
   [1,1] =  1
   [2,1] =  2
   [3,1] =  4
   [4,1] =  3
   [1,2] =  1
   [2,2] =  4
   [3,2] =  8
   [4,2] =  6
}
>  >> m2 = m1.*0.2
> error: binary operator '.*' not implemented for 'cell' by 'scalar'

m1 is not a Matrix.

May be you were looking for

octave:1> m1 = [1 1; 2 4; 4 8; 3 6]
m1 =

   1   1
   2   4
   4   8
   3   6

octave:2> m2 = m1.*0.2
m2 =

   0.20000   0.20000
   0.40000   0.80000
   0.80000   1.60000
   0.60000   1.20000




_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave



--
Jonathan Camilleri

Mobile (MT): <a href="tel:%2B%2B356%207982%207113" value="+35679827113" target="_blank">++356 7982 7113
E-mail: [hidden email]
Please consider your environmental responsibility before printing this e-mail.
 
I usually reply to emails within 2 business days.  If it's urgent, give me a call.

and, angel start-up investment opportunities available at http://slyth3.wix.com/jon-business.
Online resume is available online at http://mt.linkedin.com/in/jonathancamilleri and shared bookmarks at https://delicious.com/jon80.



_______________________________________________
Help-octave mailing list
Help -[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave

{1 1; 2 4; 4 8; 3 6} is not the same as [1 1; 2 4; 4 8; 3 6]. For the difference see the Octave manual "cell array" and "matrix".

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave




--
Jonathan Camilleri

Mobile (MT): ++356 7982 7113
E-mail: [hidden email]
Please consider your environmental responsibility before printing this e-mail.
 
I usually reply to emails within 2 business days.  If it's urgent, give me a call.

and, angel start-up investment opportunities available at http://slyth3.wix.com/jon-business.
Online resume is available online at http://mt.linkedin.com/in/jonathancamilleri and shared bookmarks at https://delicious.com/jon80.


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: binary operators not implemented for 'cell' by 'scalar' operations

nrjank
On Tue, Nov 24, 2015 at 4:31 AM, Jonathan Camilleri <[hidden email]> wrote:
This would mean that it is not yet possible to plot contents of a cell but those of a matrix, this is just something that confused me.

On 24 November 2015 at 10:13, karl <[hidden email]> wrote:
Am 24.11.2015 um 10:03 schrieb Jonathan Camilleri:
I tried this:

Read http://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

>> m1 = {1 1; 2 4; 4 8; 3 6}
m1 =
{
  [1,1] =  1
  [2,1] =  2
  [3,1] =  4
  [4,1] =  3
  [1,2] =  1
  [2,2] =  4
  [3,2] =  8
  [4,2] =  6
}
>> m2 = m1.^0.2
error: binary operator '.^' not implemented for 'cell' by 'scalar' operations
>> cell2mat(m2)
error: 'm2' undefined near line 1 column 10
error: evaluating argument list element number 1
>>

On 24 November 2015 at 10:00, Marco Atzeri <[hidden email]> wrote:


On 24/11/2015 09:56, Jonathan Camilleri wrote:
I thought I could do matrix multiplications and the mathematical
operators, but evidently I cannot.

See
https://en.wikipedia.org/wiki/Operation_(mathematics)
https://en.wikipedia.org/wiki/Algebra
https://en.wikipedia.org/wiki/Order_of_operations


  m1 = {1 1; 2 4; 4 8; 3 6}
m1 =
{
   [1,1] =  1
   [2,1] =  2
   [3,1] =  4
   [4,1] =  3
   [1,2] =  1
   [2,2] =  4
   [3,2] =  8
   [4,2] =  6
}
>  >> m2 = m1.*0.2
> error: binary operator '.*' not implemented for 'cell' by 'scalar'

m1 is not a Matrix.

May be you were looking for

octave:1> m1 = [1 1; 2 4; 4 8; 3 6]
m1 =

   1   1
   2   4
   4   8
   3   6

octave:2> m2 = m1.*0.2
m2 =

   0.20000   0.20000
   0.40000   0.80000
   0.80000   1.60000
   0.60000   1.20000




_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave



--
Jonathan Camilleri

Mobile (MT): <a href="tel:%2B%2B356%207982%207113" value="+35679827113" target="_blank">++356 7982 7113
E-mail: [hidden email]
Please consider your environmental responsibility before printing this e-mail.
 
I usually reply to emails within 2 business days.  If it's urgent, give me a call.

and, angel start-up investment opportunities available at http://slyth3.wix.com/jon-business.
Online resume is available online at http://mt.linkedin.com/in/jonathancamilleri and shared bookmarks at https://delicious.com/jon80.



_______________________________________________
Help-octave mailing list
Help -[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave

{1 1; 2 4; 4 8; 3 6} is not the same as [1 1; 2 4; 4 8; 3 6]. For the difference see the Octave manual "cell array" and "matrix".

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave




--
Jonathan Camilleri

A cell and a matrix/array are entirely different things. A cell can hold things other than numbers. A matrix can only hold numbers. A cell can also have different size elements, a matrix must be nD rectangular.  Because a cell in not necessarily numbers, there is no clear definition on what standard matrix operators would or should do.

your cell2mat attempt didn't work because you tried to run the function on m2 which didn't exist. when the error occurred, m2 was never created. so cell2mat(m2) threw an expected error. Had you tried

>> cell2mat(m1)
ans =

   1   1
   2   4
   4   8
   3   6

>> m2 = ans.^2
m2 =

    1    1
    4   16
   16   64
    9   36


things would have been fine.

 Is there a particular reason you're working with a cell array instead of a numerical array/matrix?  If you need to operate on the elements of a cell, there is the 'cellfun' command, but that's only for working on the elements individually.

Nick J.

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave