How to assign value from one matrix to another?
Afficher commentaires plus anciens
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 commentaires
Azzi Abdelmalek
le 20 Août 2015
To make your question clear, post the expected result
Drazen Tubic
le 20 Août 2015
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!