create struct with nx1 dimension
60 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Marc Janousek
am 6 Jan. 2020
Kommentiert: Marc Janousek
am 6 Jan. 2020
Hi !
I am looking for a way to create an empty struct with the dimensions 2x1.
So far i only know the comment
StructName = struct
which creates a struct with the dimensions 1x1
Thank you very much in advance!
Marc
2 Kommentare
Stephen23
am 6 Jan. 2020
Bearbeitet: Stephen23
am 6 Jan. 2020
A struct with size 2x1 is not empty, it has two elements.
Empty means that at least one dimension has zero size.
The number of fields a structure has is unrelated to its size.
You can easily create a 2x1 (i.e. not empty) structure with no fields:
S = repmat(struct(),2,1)
Akzeptierte Antwort
Max Murphy
am 6 Jan. 2020
StructName = struct('FieldName1',cell(2,1),'FieldName2',cell(2,1));
% or
StructName = struct('FieldName1',[],'FieldName2',[]);
StructName = repmat(StructName,2,1);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Structures 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!