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

2 vues (au cours des 30 derniers jours)
Jeevan Kumar Bodaballa
Jeevan Kumar Bodaballa le 25 Mai 2020
Commenté : John D'Errico le 25 Mai 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

Réponse acceptée

Ameer Hamza
Ameer Hamza le 25 Mai 2020
Modifié(e) : Ameer Hamza le 25 Mai 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 commentaires
Jeevan Kumar Bodaballa
Jeevan Kumar Bodaballa le 25 Mai 2020
Thank you
John D'Errico
John D'Errico le 25 Mai 2020
It seemed clear this was just a slip of the brain.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by