Divide elements between 2 matrices
20 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
N.
le 10 Avr 2016
Modifié(e) : Azzi Abdelmalek
le 10 Avr 2016
I have a matrix
M1 =[4 3 6 8 1 10 5 2 9 4 5 6
1 10 3 9 4 2 5 7 6 5 4 3
9 5 1 7 8 10 3 4 2 6 5 1];
M2 =[1 6 3 5
3 5 9 6
2 1 9 5];
If it is column 1, 5, or 9 in M1 then divide by column 1 in M2 If it is column 2, 6, or 10 in M1 then divide by column 2 in M2 If it is column 3, 7, or 11 in M1 then divide by column 3 in M2 If it is column 4, 8, or 12 in M1 then divide by column 4 in M2
and it will give an output of a matrix 3x12
output =[4 0.5 2 1.6 1 1.66667 1.66667 0.4 ...
0.33 2 0.33 1.5 1.33 0.4 0.5556 1.116 ...]
.
.
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 10 Avr 2016
Modifié(e) : Azzi Abdelmalek
le 10 Avr 2016
M1 =[4 3 6 8 1 10 5 2 9 4 5 6
1 10 3 9 4 2 5 7 6 5 4 3
9 5 1 7 8 10 3 4 2 6 5 1];
M2 =[1 6 3 5
3 5 9 6
2 1 9 5];
[n,m]=size(M1);
a=reshape(M1,n,4,[]);
b=bsxfun(@rdivide, a,M2);
out=b(:,:)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!