Who do I create a sequence of matrices?
Mostrar comentarios más antiguos
Hello everybody!
I need to create a sequence of matrices of the following form. For example: From the input:
1 2 0
x = 0 0 0
0 0 0
I need to get:
1 0 0 1 1 0 1 2 0 0 1 0 0 2 0
y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
That is, I need to get a "combinatoric" sequence of matrices from the one input. The size of the matrix can vary. Is there any suitable function for this? Thank you.
11 comentarios
Azzi Abdelmalek
el 17 de Nov. de 2012
What is the relation y=f(x)
Walter Roberson
el 17 de Nov. de 2012
Editada: Walter Roberson
el 17 de Nov. de 2012
Why are multiple 1 allowed? And not multiple 2 ? Why is the first matrix different from the fourth and yet none of the matrices show a 2 in the first column ?
SomeUser
el 17 de Nov. de 2012
Azzi Abdelmalek
el 17 de Nov. de 2012
Editada: Azzi Abdelmalek
el 17 de Nov. de 2012
it's still not clear for me. How x and y are related?
SomeUser
el 17 de Nov. de 2012
the cyclist
el 17 de Nov. de 2012
What people are saying here is that we do not understand the rule for generating y from x. Please give more than a one-sentence explanation. Is your example y ALL the values that you would expect from that x? Please trust us when we say it is simply not at all clear what the output should be for general x.
The rule seems to be:
For each non-zero value in x, generate a set of matrices where that value is held fixed while all other values vary from 0 to the value. So you can see there is a 1 and a 2. So hold the 1 fixed and generate matrices by letting the element in the position of the 2 vary from 0 to 2. Then hold the 2 fixed and generate matrices by letting the element in the 1 position vary from 0 to 1.
Or something like that....
So there is a typo in y??
SomeUser
el 17 de Nov. de 2012
Matt Fig
el 17 de Nov. de 2012
SomeUser, that code produces an error with the x you show....
x = [1 2 0;0 0 0;0 0 0];
Error using cat
CAT arguments dimensions are not consistent.
Error in for_loop3 (line 13)
y = cat(3, y, matrix);
Matt Fig
el 17 de Nov. de 2012
Ah, o.k. Thanks.
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 17 de Nov. de 2012
0 votos
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!