필터 지우기
필터 지우기

I want to extract cell array

조회 수: 2 (최근 30일)
Habtamu Tsegaye
Habtamu Tsegaye 2022년 4월 13일
답변: 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