Insert first value in vector into next 11 lines using an If loop

I have a vector 8754x1 with hourly temperature data in it for a whole year. I have created a new vector and inserted 11 rows of zeros between each temperature point in order to create a time series of 5 minutes data with 105048 rows. This means the 1st, 13th, 25th etc. rows have temperature data in them and the 2-12, 14-24, 26-36 etc. rows have zeros in them.
I would like to copy the temperature data from row 1 into rows 2-12 and then go onto copy the temperature data from row 13 into rows 14-24 for the whole data set. I think I need to use an ‘if’ loop to do this, but I am new to Matlab and I am not sure where to start. Any help would be gratefully received.

 採用された回答

James Tursa
James Tursa 2016 年 10 月 14 日
編集済み: James Tursa 2016 年 10 月 14 日

0 投票

This follows your specified pattern using the repmat function:
T = your 8754x1 temp data vector
Tresult = reshape(repmat(T',12,1),[],1);

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2016 年 10 月 14 日

コメント済み:

2016 年 10 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by