Effacer les filtres
Effacer les filtres

I need to divide two matrix with different rows and column

6 vues (au cours des 30 derniers jours)
rajasekar dhandapani
rajasekar dhandapani le 18 Juin 2019
Modifié(e) : Adam Danz le 19 Juin 2019
Hi Everyone,
I have two Matrix
A= 1x12
B=11x12
I want to divide D=A(of 1st element) / B(of complete Row)
now D should have 11 Rows which all divided by 1st element in A
Is it possible to do with for loop?
Thanks a lot..!

Réponse acceptée

Adam Danz
Adam Danz le 18 Juin 2019
Modifié(e) : Adam Danz le 18 Juin 2019
Your description asks for two different things.
"I want to divide D=A(of 1st element) / B(of complete Row)"
% Fake data
A = randi(20,1,12);
B = randi(20,11,12);
D = A(1,1)./B
"D should have 11 Rows which all divided by 1st element in A"
D = B / A(1,1);
Or do you want to divide each column of A by the columns in B?
D = A ./ B;
  2 commentaires
rajasekar dhandapani
rajasekar dhandapani le 18 Juin 2019
Modifié(e) : rajasekar dhandapani le 18 Juin 2019
This only calculates 1 row.
Please find my data in the attachement.
A is 1X12 B is 11X12
Each number of columns in A should be divided by B and the result should also be in 11X12
For example D should look like
7.2 (which is 36.1/5.19) 5,6(which is 33,33/5,88) ..................
7.16 (which is 36,1/5,04) 5,56(Which is 33,33/5,99) ....................
. .
. .
so on
Adam Danz
Adam Danz le 18 Juin 2019
Modifié(e) : Adam Danz le 19 Juin 2019
The fake data I created fits your description. Check out the last line in my answer. It does what you're describing. Here's another example
D = [1 2 3] ./ [1 1 1; 2 2 2; 3 3 3];

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing 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!

Translated by