inserting rows in a matrix

1 回表示 (過去 30 日間)
Ali Ekhtiari
Ali Ekhtiari 2019 年 9 月 3 日
コメント済み: Andrei Bobrov 2019 年 9 月 4 日
The matrix has 365 rwos and one column(365*1).
I want to add 24 zero rows below the every row. If I want to explain more, I would say, I have daily average of a year (365 days), then I want to change this 365 days to 8760 rwos to put each number with 24 rows distance in between of each number in new matrix.
How can I do this?
Thanks

回答 (4 件)

Andrei Bobrov
Andrei Bobrov 2019 年 9 月 3 日
kron(yourmatrix(:),[1;zeros(24,1)]);

Steven Lord
Steven Lord 2019 年 9 月 3 日
Are you trying to turn daily data into hourly data? If so, consider making datetime vectors for each day and each hour and passing those (along with your daily data) into interp1, like the "Interpolation of Dates and Times" example on the interp1 documentation page shows. Alternately if you're storing your data in a timetable call retime on it.
  1 件のコメント
Andrei Bobrov
Andrei Bobrov 2019 年 9 月 4 日
+1

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


Walter Roberson
Walter Roberson 2019 年 9 月 3 日
reshape([YourMatrix.'; zeros(24, 365)], [], 1)

madhan ravi
madhan ravi 2019 年 9 月 3 日
編集済み: madhan ravi 2019 年 9 月 4 日
Wanted=zeros(365*25,1);
Wanted(1:25:end) = yourmatrix
  2 件のコメント
Walter Roberson
Walter Roberson 2019 年 9 月 3 日
I think you have an off-by-one error. According to the description, they want 24 rows of zeros below each row, which would make a total of 25 for the group.
madhan ravi
madhan ravi 2019 年 9 月 4 日
Ah thank you sir Walter, I was confused when the OP mentioned 8760 and then reading it again the first line states 24 zeros rows after each ..

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

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by