Argument to dynamic structure reference must evaluate to a valid field name
古いコメントを表示
Here is a code snippet that results in the error message recorded in my question. The program passes the if clause that starts
if isfield...
but baulks (North America: balks) at the next line. I hope that it is obvious to a human reader what I am trying to do. How do I make it obvious to Matlab? Have I given enough info so that someone can help me? I would be happy to give more if required.
for fldn={'raw','scl','svd','pft'}
if isfield(R,(fldn))
err = X*(R.(fldn).coef - Y);
R.(fldn).err = num2cell(mean(err.^2));
end
end
Here are some answers given by the Matlab debugger:
fldn
ans='raw'
R.fldn;
Reference to a non-existent field
R.(fldn);
Argument to dynamic structure reference must evaluate to a valid field name.
R.raw
ans=coef: {[21x1 double]}
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Debugging and Improving Code についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!