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

1 次查看(过去 30 天)
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 个评论

请先登录,再进行评论。

更多回答(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