rempet
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I have a matrix and a vector, I want to repmat them the same my mean is that if I change the first row of the matrix I want this also happen the same for the vector,
2 comentarios
Oleg Komarov
el 7 de Sept. de 2011
Your request doesn't make sense without additional information. What's your goal? How the change happens?
Respuesta aceptada
Fangjun Jiang
el 7 de Sept. de 2011
X=rand(4)
Y=rand(4,1)
Index=[2 3 4 1];
X=X(Index,:)
Y=Y(Index,:)
5 comentarios
Fangjun Jiang
el 7 de Sept. de 2011
You are welcome! BTW, Index=randperm(4);X=X(Index,:); works too!
Más respuestas (2)
Honglei Chen
el 7 de Sept. de 2011
An alternative approach is to use left-multiply to achieve row manipulation. In your case, if you want to move your first row to the last, the corresponding matrix is
T = [0 1 0 0;0 0 1 0;0 0 0 1;1 0 0 0]
Then you can do
X = T*X
Y = T*Y
As long as you can build T, then you can the manipulate them together.
HTH
Walter Roberson
el 7 de Sept. de 2011
What you are asking to do is not possible with ordinary numeric datatypes.
You could create a new object-oriented data class that did the work for you.
0 comentarios
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!