I need to divide two matrix with different rows and column

4 Ansichten (letzte 30 Tage)
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..!

Akzeptierte Antwort

Adam Danz
Adam Danz am 18 Jun. 2019
Bearbeitet: Adam Danz am 18 Jun. 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 Kommentare
rajasekar dhandapani
rajasekar dhandapani am 18 Jun. 2019
Bearbeitet: rajasekar dhandapani am 18 Jun. 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 am 18 Jun. 2019
Bearbeitet: Adam Danz am 19 Jun. 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];

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by