Help needed in creating dynamic field names using struct in matrix form.

1 回表示 (過去 30 日間)
Rick
Rick 2012 年 10 月 24 日
編集済み: Stephen23 2016 年 1 月 12 日
Hi,
I am currently using this code:
rename = sprintf('I%inewEp', i);
newData.(rename) = myData.Ep;
newData.(rename(:,1)) = myData.Ep(:,1) - X; %Error starts from here
newData.(rename(:,2)) = myData.Ep(:,2) - Y;
I keep getting errors when the code performs the subtractions.
Any suggestions would be greatly appreciated. Thank you.

採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 10 月 24 日
newData.(rename) = bsxfun(@minus,myData.Ep,[X Y]);

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by