Loop Rate of Change with Negative Values

1 回表示 (過去 30 日間)
IDN
IDN 2022 年 1 月 19 日
コメント済み: IDN 2022 年 1 月 22 日
Hello,
I would like to use a loop to calculate across a table a rate of change ( (Current Value - 4thValue) / 4th Value)).
I tried using "prcroc" but i doesnt work on negative values. Please see time series attached.
Thanks!

採用された回答

Mathieu NOE
Mathieu NOE 2022 年 1 月 20 日
hello
I assumed that the time axis in your file is as folows : first (top value) is the oldest and last (bottom) is the newest
clc
clearvars
data = xlsread('VBC.xlsx');
% time axis supposed : first (top value) is the oldest and last (bottom) is the newest
% rate of change = (data(index) - data(index - 4))/data(index - 4)
RoC(1:4) = 0;
for ck = 5:numel(data)
RoC(ck) = (data(ck) - data(ck - 4))/data(ck - 4);
end
plot(RoC)
  1 件のコメント
IDN
IDN 2022 年 1 月 22 日
Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by