Filter löschen
Filter löschen

how to create a structure?

2 Ansichten (letzte 30 Tage)
UPT
UPT am 14 Sep. 2012
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 Kommentar
UPT
UPT am 14 Sep. 2012
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).

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 14 Sep. 2012
Bearbeitet: Walter Roberson am 14 Sep. 2012
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 Kommentare
Andrei Bobrov
Andrei Bobrov am 14 Sep. 2012
FN = cellstr(('A':'F')');
d = [FN'; repmat({zeros(20,1)},1,numel(FN))];
YourStruct = struct(d{:});
Walter Roberson
Walter Roberson am 14 Sep. 2012
Looks like that would miss that A should become cell(20,1)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by