MATLAB: Finding ratio between two elements of one Array

arraydivideratio

Hi there,
I have an array that looks like this:
Array =
1 2 3 4 5 6 7 8 9
I would like to find the ratio between two elements in this array. For example 1/2, 2/3, 3,4, 4,5… etc
I came up with this code
ratio = [];
for i = 1:length(Array)
ratio(i) = Array(i)/Array(i+1)
end
but the problem is that the last iteration gives me error (last index +1) 🙁
how can I overcome this problem. Thank you in advance

Best Answer

for i = 1:length(Array)-1