How to add time values in a table column with a loop?

1 回表示 (過去 30 日間)
Ramo Rafsel
Ramo Rafsel 2020 年 11 月 9 日
コメント済み: Ramo Rafsel 2020 年 11 月 9 日
I would like to fill an already existing table (which is the Frequency) with increasing values (increment) in a table from the start (time(1)) until the end time (time(end)) which should look like this when I plot it : time(1):increment:time(end).
and each row should look like this:
firstrow =time(1)
row1=time(1)+increment
row2= row1+increment
row3=row2+increment
.
.
lastrow=time(end)
Thanks a lot in advance for the help!
fr= Frequency.fb;
timelength=time(end)-time(1);
frlaenge=round(seconds(256));
frlaenge.Format="hh:mm:ss";
increment=round(seconds(timelength/frlaenge));
increment.Format="hh:mm:ss";
fr = double(split(string(fr(1:end-1)) , ","));
fr = fr(:,1);
all(size(increment)) = all(size(fr))

採用された回答

Cris LaPierre
Cris LaPierre 2020 年 11 月 9 日
Assuming your times are already datetimes, I would just do the following.
t = linspace(time(1),time(end),height(Frequency));
Frequency.t = t';
  1 件のコメント
Ramo Rafsel
Ramo Rafsel 2020 年 11 月 9 日
This is a way better idea than what I was trying to do. Thanks a lot for the help :)

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by