Divide consecutive numbers and put them in a table

5 visualizaciones (últimos 30 días)
Pawel Kaszynski
Pawel Kaszynski el 19 de Feb. de 2022
Editada: Image Analyst el 19 de Feb. de 2022
TotalReturnIndexLevel
_____________________
12/31/2019 100
1/31/2020 90.3
2/28/2020 104.75
3/31/2020 115.01
4/30/2020 123.18
5/31/2020 139.81
6/30/2020 131.28
7/31/2020 137.71
8/31/2020 145.56
How can I divide consecutive numbers and put them in a table.
For example
90.3/100 = 0.903
104.75/90.3 = 1.16
But make it automatic for a long list and put the outcomes in a table

Respuestas (1)

Image Analyst
Image Analyst el 19 de Feb. de 2022
Editada: Image Analyst el 19 de Feb. de 2022
Assuming v is your vector of numbers
ratios = v(2:end) ./ v(1:end-1)
% Create table
t = table(ratios(:), 'VariableNames', {'Ratios'})

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by