フィルターのクリア

Add nan matrix where I have no data

1 回表示 (過去 30 日間)
kounoupaki87
kounoupaki87 2020 年 5 月 21 日
コメント済み: kounoupaki87 2020 年 5 月 21 日
Hi,
  • I have a matrix (Data) which is (198x104x24): this contains data for January but some dates are missing.
  • I have these days in a different file (Missingdates): days where I don't have any data and I want to add nan matrix
I would like to have a matrix with dimensions: (198x104x31).
Example: I don't have any data for 02/01, so I would like to add a matrix (in the 3rd dimension) AddNan=nana(198,104);
  1 件のコメント
Walter Roberson
Walter Roberson 2020 年 5 月 21 日
Perhaps create a timetable object and retime() with method 'fillwithmissing'

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

採用された回答

Cris LaPierre
Cris LaPierre 2020 年 5 月 21 日
A bit convoluted, but try this. The main challenge is you don't have any dates associated with data, so creating that is a bit interesting.
load data.mat
load Missingdates.mat
% Create a vector of dates for the month
date = dateshift(Missingdates(1),"start","month"):days(1):dateshift(Missingdates(1),"end","month");
date(ismember(date,Missingdates))=[]; % delete the missing dates
date = [date Missingdates']; % Add missing dates to the end of the date vector
[~, ind]=sort(date); % determine the order to place the dates in
% Create the empty matrices and concatenate to data along 3rd dimension
newData = nan([size(data,1:2),length(Missingdates)]);
newData = cat(3,data, newData);
% redorder the 3rd dimension of data to place sheets in date order
newData = newData(:,:,ind)
  2 件のコメント
kounoupaki87
kounoupaki87 2020 年 5 月 21 日
Something is wrong when concatenate arrays:/
kounoupaki87
kounoupaki87 2020 年 5 月 21 日
Oh Ok, just the size was opossite:) Thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by