How to calculate log(a/b) for each two rows at each column ?

조회 수: 2 (최근 30일)
Jeevan Kumar Bodaballa
Jeevan Kumar Bodaballa 2020년 5월 25일
댓글: John D'Errico 2020년 5월 25일
I have a matrix mXn for example
a = 2 3 6 5 7 4
5 4 7 8 9 6
4 5 8 9 8 5
And from above 3X6 matrix i want to calculate log(second row/first rown) at each column
Then finally I will have 2X6 matrix
How can I solve for mXn matrix ?
I use this code
for i = 1:3
for j = 1:6
dlogd = log(a(i+1,j)/a(i,j));
end
end

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 5월 25일
편집: Ameer Hamza 2020년 5월 25일
a = ...
[2 3 6 5 7 4
5 4 7 8 9 6
4 5 8 9 8 5];
b = log(a(2:end, :)./a(1:end-1,:));
Result
>> b
b =
0.9163 0.2877 0.1542 0.4700 0.2513 0.4055
-0.2231 0.2231 0.1335 0.1178 -0.1178 -0.1823
  댓글 수: 4
John D'Errico
John D'Errico 2020년 5월 25일
It seemed clear this was just a slip of the brain.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by