creating and referencing matrices

Can I define and reference a matrix like MatLab?

a = [1 2 ; 3 4; 5 6]

would be the matrix

1 2
3 4
5 6

and i could reference it where

a(2,1) = 4

does this work with the Arduino environment?

Much thanks!

a = [1 2 ; 3 4; 5 6]

Will be:

byte a[][] = { 
  {1,2},
  {3,4},
  {5,6}
};

And you reference it by:

//a(2,1) = 4
byte value = a[1][1];//value becomes 4

[edit]And, by doing:

a[2][0] = 7;

The cell that used to be 5, is now 7.[/edit]

Thank you very, very much! I am surprised it was not listed on the reference page, on the Arduino web site, Thanks again.

I am surprised it was not listed on the reference page, on the Arduino web site

It is, but you'd have to know that they're called "Arrays": http://arduino.cc/en/Reference/Array

Andrew

I did look under arrays on the reference page, but it didn't make a mention of the declaration and indexing of multidimensional arrays. pretty straight forward though non the less. Thanks.

-Michael

A matrix and multidimentional array are synonymous, no?

Lefty

A matrix and multidimentional array are synonymous, no

I think that in mathematics, a vector is single dimensional array, a matrix is a 2 dimensional array and anything above 2 dimensions is a tensor.