>>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.

 채택된 답변

Paul
Paul 2023년 6월 3일
편집: Paul 2023년 6월 6일

2 개 추천

% 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
Sis = 1×82 struct array with fields:
PV
sum([Sis.PV])
ans = 1640
See this tutorial on how to use comma separated lists.

댓글 수: 3

shamal
shamal 2023년 6월 3일
Thank you.. But why you use []? I dont uderstand
Paul
Paul 2023년 6월 3일
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".
Paul
Paul 2023년 6월 6일
I just realized I had a mistake in my example. I'll edit the Answer.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Structures에 대해 자세히 알아보기

질문:

2023년 6월 3일

편집:

2023년 6월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by