Divide consecutive numbers and put them in a table

5 Ansichten (letzte 30 Tage)
Pawel Kaszynski
Pawel Kaszynski am 19 Feb. 2022
Bearbeitet: Image Analyst am 19 Feb. 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

Antworten (1)

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

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by