How to assign value from one matrix to another?
Mostrar comentarios más antiguos
M=ones(14,2);
M(:,1)=1:14;
G=ones(20,2);
for o=1:20;
G(o,1)=ceil(14*rand);
G(o,2)=6.5*rand;
end
I want to assign values from matrix G to matrix M, with constraints that values from G(:,1) iteratively compare to those in M(:,1) and then assign value from the matching row to the second column. For example, if values in the first row of the matrix M are 1, 1, and if the values in the fifth row of the matrix G are 1, 5, i want to asign that value 5 to the first row, second column of the matrix M, which would then look like this: 1, 5.
I hope i wrote my problem understandable. Thank you for answers.
EDIT:


Now, for the first iteration, i want matrix A to look like this:

for second iteration like this:

and so forth. I need this because i want to do calculations for every iteration separately.
2 comentarios
Azzi Abdelmalek
el 20 de Ag. de 2015
To make your question clear, post the expected result
Drazen Tubic
el 20 de Ag. de 2015
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Logical 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!