MATLAB: How to calculate ratio of elements of a column

ratio of elements of the same column

I want to calculate the ratio of elements of each column. For ex: my column has data A = [ 1;2;3;4;5;6;7;8;9;10] and I want to calculate the ratio of elements for which the numerator and denominator are the elements of the consecutive rows leaving the first row. B(1) = 2/1, B(2) = 3/2, B(3) = 4/3, and so on.. finally B = [2; 3/2; 4/3; 5/4;…]

Best Answer

>> B = A(2:end)./A(1:end-1)
B =
2
1.5
1.3333
1.25
1.2
1.1667
1.1429
1.125
1.1111