필터 지우기
필터 지우기

how to create a structure?

조회 수: 2 (최근 30일)
UPT
UPT 2012년 9월 14일
i want to create a structure with these dimensions: A: 20*1 cell, B: 20*1 double, C: 20*1 double, D: 20*1 double, E: 20*1 double, F: 20*1 double. please help me.thank you.
  댓글 수: 1
UPT
UPT 2012년 9월 14일
thanks for your help.let's supose that 'A and 'B' are 'Date' and 'Hour'.'F' is 'NumDate'.how can i convert date and hour to numdate??..('Date' has 3 months of data and 'Hour' has 24).

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2012년 9월 14일
편집: Walter Roberson 2012년 9월 14일
YourStruct = struct('A', {cell(20,1)}, 'B', {zeros(20,1)}, 'C', {zeros(20,1)}, 'D', {zeros(20,1)}, 'E', {zeros(20,1)}, 'F', {zeros(20,1)});
Or if you prefer,
YourStruct.A = cell(20,1);
for FN = 'BCDEF'
YourStruct.(FN) = zeros(20,1);
end
  댓글 수: 2
Andrei Bobrov
Andrei Bobrov 2012년 9월 14일
FN = cellstr(('A':'F')');
d = [FN'; repmat({zeros(20,1)},1,numel(FN))];
YourStruct = struct(d{:});
Walter Roberson
Walter Roberson 2012년 9월 14일
Looks like that would miss that A should become cell(20,1)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by