필터 지우기
필터 지우기

I need to divide two matrix with different rows and column

조회 수: 6 (최근 30일)
rajasekar dhandapani
rajasekar dhandapani 2019년 6월 18일
편집: Adam Danz 2019년 6월 19일
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일
편집: 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