I need to divide two matrix with different rows and column

6 次查看(过去 30 天)
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..!

采纳的回答

Adam Danz
Adam Danz 2019-6-18
编辑:Adam Danz 2019-6-18
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 个评论
rajasekar dhandapani
编辑:rajasekar dhandapani 2019-6-18
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 2019-6-18
编辑:Adam Danz 2019-6-19
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];

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by