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

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 日

0 投票

newData.(rename) = bsxfun(@minus,myData.Ep,[X Y]);

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStructures についてさらに検索

質問済み:

2012 年 10 月 24 日

編集済み:

2016 年 1 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by