changing time interval of interest in a dataset

1 回表示 (過去 30 日間)
C.G.
C.G. 2022 年 7 月 11 日
コメント済み: Kapil Kumar 2022 年 7 月 11 日
My code below uses my data, and follows the equation Q_i+1 - Q_i/time
The time interval of interest changes as defined by time. However as well as the time interval changing, I want matlab to change the numbers from the data.
When dt = 1: Q_i+1 - Q_i /1
When dt = 2: Q_i+2 - Q_i /2
Whhen dt = 3: Q_i+3 - Q_i /3
And so forth up to the end of the defined time range.
The code below works when time = 1, but im struggling to change the part (M(2:end) - M(1:end)) to follow the rule defined above
time = 1:1:10; %increasing time intervals of interest up to Trw
for a = 1:length(time)
M_s = (M(2:end) - M(1:end))/time(a); %each time step
end

回答 (1 件)

Kapil Kumar
Kapil Kumar 2022 年 7 月 11 日
time = 1:1:10;
for a = 1:length(time)
M_s = (M((a+1):end) - M(1:end))/time(a); %each time step
end
If this code is working fine for time=1 then this might help.
  4 件のコメント
C.G.
C.G. 2022 年 7 月 11 日
I can't fix it as such, because I want it to go up in increasing time intervals through the dataset M.
Kapil Kumar
Kapil Kumar 2022 年 7 月 11 日
you can use length of M instead of length of time (in line 2)
and also for time you can make length of time same as the length of M
then it will work fine. If there is no time contraints.

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by