How to calculate log(a/b) for each two rows at each column ?
1 view (last 30 days)
Show older comments
Jeevan Kumar Bodaballa
on 25 May 2020
Commented: John D'Errico
on 25 May 2020
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
0 Comments
Accepted Answer
Ameer Hamza
on 25 May 2020
Edited: Ameer Hamza
on 25 May 2020
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 Comments
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!