If I have a 4x4 cell array, 'm' where each element is a matrix expressed as '4x4 double', what would be the notation to access the values of a matrix within 'm'.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Andrew Wiebe
el 23 de Sept. de 2015
say m = 4x4 double 4x4 double 4x4 double 4x4 double
4x4 double 4x4 double 4x4 double 4x4 double
4x4 double 4x4 double 4x4 double 4x4 double
4x4 double 4x4 double 4x4 double 4x4 double
each 4x4 when opened is a matrix. say the matrix '4x4 double' in row one column one of 'm', has a value of one in it's first row and first column so [1,1]=1 of the first row first column of matrix 'm' . how could i access that without assigning each 4x4 double its own variable. for instance, could i do 1=m{1,[1,1], 1}?
3 comentarios
James Tursa
el 24 de Sept. de 2015
Editada: James Tursa
el 24 de Sept. de 2015
"...the term "matrix" is often understood to refer to numeric arrays."
Is this documented somewhere? I had never heard that before, and not sure I even agree with it. I have always understood the term "matrix" in MATLAB to be a 2D object ... any object. E.g., read the doc for transpose and it talks about operations on a "matrix". The doc states that this works for numeric, char, logical, cell, struct, class objects, etc. Clearly the term matrix is used in a generic 2D sense here. Other places in the doc sometimes refer to both "matrices" and "cell arrays" in the same sentence, so the doc isn't even consistent here.
I would have said if one wants to be specific about numeric 2D objects then one can use the term "numeric matrix".
Stephen23
el 25 de Sept. de 2015
Editada: Stephen23
el 25 de Sept. de 2015
https://en.wikipedia.org/wiki/Matrix_(mathematics): "In mathematics, a matrix (plural matrices) is a rectangular array[1]—of numbers, symbols, or expressions, arranged in rows and columns" (the entirety of this page explains properties of numeric matrix manipulation).
http://mathworld.wolfram.com/Matrix.html: "A matrix is a concise and useful way of uniquely representing and working with linear transformations..." (i.e. numeric values and their abstractions)
http://dictionary.reference.com/browse/matrix: " 11. Mathematics. a rectangular array of numbers, algebraic symbols, or mathematical functions, especially when such arrays are added and multiplied according to certain rules. " (clearly numeric and their abstractions)
http://www.oxforddictionaries.com/definition/english/matrix: "4 Mathematics A rectangular array of quantities or expressions in rows and columns that is treated as a single entity and manipulated according to particular rules:" (i.e. numeric values and their abstractions)
That the meaning of matrix has been applied to other data structures is hinted at by Merriam Webster:
http://www.merriam-webster.com/dictionary/matrix: "5 a : a rectangular array of mathematical elements (as the coefficients of simultaneous linear equations) that can be combined to form sums and products with similar arrays having an appropriate number of rows and columns b : something resembling a mathematical matrix especially in rectangular arrangement of elements into rows and columns "
I did not state that "matrix" does not also refer to cell arrays, structures and other data classes within MATLAB, I stated that "the term "matrix" is completely ambiguous", because, exactly as you point out, it can be applied in MATLAB to many different classes of data.
Respuesta aceptada
James Tursa
el 23 de Sept. de 2015
For a cell array m,
m(i,j) is the i'th row, j'th column element of m. m(i,j) is a 1x1 cell array.
m{i,j} is the _contents_ of the i'th row, j'th column element of m. In your case a 4x4 double.
m{i,j}(x,y) is the x'th row, y'th column element of the 4x4 double array in m{i,j}. A 1x1 scalar double.
m{i,j}(x,y) = 6; Sets the x'th row, y'th column element of the 4x4 double array in m{i,j} to 6.
v = m{i,j}(x,y); Sets the variable v equal to the x'th row, y'th column element of the 4x4 double array in m{i,j}.
0 comentarios
Más respuestas (1)
Andrew Wiebe
el 23 de Sept. de 2015
1 comentario
James Tursa
el 23 de Sept. de 2015
Editada: James Tursa
el 23 de Sept. de 2015
You will need to show your code so we can see what you are doing and offer suggestions on how to correct things. If this is unrelated to the original cell array indexing question above, you should open up a new Question.
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!