Create a matrix with values in a specific position from another matrix

1 回表示 (過去 30 日間)
stelios loizidis
stelios loizidis 2020 年 5 月 20 日
コメント済み: Ameer Hamza 2020 年 5 月 21 日
Hello, I have a matrix with hourly prices for a product. That, is 24 prices for one day. Also, these prices are for one month. I want to create another matrix that will have the following struxture: In first 24 places enter the prices of the first day (Monday-1/6). Then, in the next 24 places to enter the prices of the day after a week, ie those of Monday (7/6). Still, let the next prices come from in on Monday (14/6). The same should be done with the next days (Tuesday, Wednesday,......Sunday). How is this done?
Your help is important!!!!!

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 5 月 20 日
編集済み: Ameer Hamza 2020 年 5 月 20 日
Try this
A = (1:720).'; % example values for 1 month
num_weeks = ceil(numel(A)/168); % 168 are hours per week
idx = repmat(repelem((1:7).', 24, 1), num_weeks, 1);
idx(numel(A)+1:end, :) = [];
split_data = splitapply(@(x) {x}, A, idx);
It creates a cell array with seven elements. Each element contains values for a particular day.
  2 件のコメント
stelios loizidis
stelios loizidis 2020 年 5 月 21 日
Thank you very much!!!!!
Ameer Hamza
Ameer Hamza 2020 年 5 月 21 日
I am glad to be of help.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by