Multiplication of two fields in a structure array

조회 수: 7(최근 30일)
SS 2020년 1월 15일
댓글: SS 2020년 1월 16일
Hi. I want to perform element wise multiplication of two fields in a struture array. The size of the fields is same throughout for a given Struct(i). When, I use the code below it gives the following error:
"Argument to dynamic structure reference must evaluate to a valid field name"
for i=1:length(Struct)
  댓글 수: 2
Guillaume 2020년 1월 15일
Are you sure that it's the exact code with no modification that you're running?
This code doesn't have any dynamic structure reference so it would be very surprising for you to get the error stated. Now, if you had something like:
Struct(i).(something) %brackets around something make it a dynamic struct ref
then yes, you could get this type of error.

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

채택된 답변

Steven Lord
Steven Lord 2020년 1월 15일
You made a typo on this line.
There shouldn't be a period between Struct and (i) in the sin call.
  댓글 수: 2
SS 2020년 1월 16일
Thank you.

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

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by