sum filed in struct
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
>>Sis.PV
ans =
20
ans =
20
ans =
20
Sis =
1×82 struct array with fields:
Name
On
PV
>> sum(Sis.PV)
Error using sum
Too many input arguments.
0 Kommentare
Akzeptierte Antwort
Paul
am 3 Jun. 2023
Bearbeitet: Paul
am 6 Jun. 2023
% example data
Sis.PV = 20;
% Sis.PV = repmat(Sis.PV,1,82); % original incorrect line, expanded the field instead of the struct
Sis = repmat(Sis,1,82); % correct line, expands the struct
Sis
sum([Sis.PV])
3 Kommentare
Paul
am 3 Jun. 2023
Yes, I used []. Read the tutorial at the link I provided in the answer for more info. And/or search the doc for "comma-separated lists".
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!