I have a structure and I need to assign a value to it , I cannot make a comma separated list here. Any suggestions? Matlab documentation on structures doesn't help me out

1 回表示 (過去 30 日間)
utsav kakkad
utsav kakkad 2018 年 10 月 22 日
コメント済み: KSSV 2018 年 10 月 22 日
More specifically I need to do this: STATISTICS.DEAD(h,r+1)=dead; Now this section comes within a for loop containing the r variable. This pops out the error: Scalar structure required for this assignment.
  2 件のコメント
Walter Roberson
Walter Roberson 2018 年 10 月 22 日
For that error to occur, STATISTICS must be a non-scalar structure at that point. The code appears to be expecting it to be a scalar structure.
Is the variable dead expected to somehow hold information to assign into each member of the non-scalar structure? If so, what data type is dead ?
Or is dead a scalar, and you want to go through all members of the non-scalar STATISTICS structure and assign that value to that location? If so the easiest way is to loop,
for D = 1 : numel(STATISTICS)
STATISTICS(D).DEAD(h,r+1) = dead;
end
KSSV
KSSV 2018 年 10 月 22 日
Why don't you show us the whole code? what is dead? String , scalar or vector?

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by