I want to extract cell array

2 次查看(过去 30 天)
Habtamu Tsegaye
Habtamu Tsegaye 2022-4-13
I do have 1x7 cell arraiy which contain 5488x4. 1st col is year, 2nd col is month, 3rd isday and 4th is the dily rainfall. I want to extract the daily data from each cell and make other cell aray contain 7 daily rainfall elements. How can I do the code? here is my data
it is my trial
for i=1:length(unistsrfr1)
for j = 1:5844
dy_strfr1= rfdata_tsstrfr1{1,i}(1:j,4);
yy= rfdata_tsstrfr1{1,1}(1:j,1);
mm= rfdata_tsstrfr1{1,1}(1:j,2);
dd= rfdata_tsstrfr1{1,1}(1:j,3);
datenum(yy,mm,dd,0,0,0)
end
end

回答(2 个)

Walter Roberson
Walter Roberson 2022-4-13
rf_cell = cellfun(@(C) [datenum(C(:,1), C(:,2), C(:,3)), C(:,4)], unistsrfr1, 'uniform', 0);
The result, rf_cell, will be a 1 x 7 cell array, each entry of which is a 5488 x 2 double, with the first column containing the datenum and the second column containing the rainfall.
Note: these days we recommend that you use datetime() objects instead of datenum()

Habtamu Tsegaye
Habtamu Tsegaye 2022-4-13
The result, rf_cell, will be a 1 x 7 cell array, each entry of which is a 5488 x 2 double. I do not need 5488X2double. what I need is 1X7 or 7X1 rainfall elements taken (one by one) from each 1X7cell array in the data attached.

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by