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

5 vues (au cours des 30 derniers jours)
Rick
Rick le 24 Oct 2012
Modifié(e) : Stephen23 le 12 Jan 2016
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.

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 24 Oct 2012
newData.(rename) = bsxfun(@minus,myData.Ep,[X Y]);

Plus de réponses (0)

Catégories

En savoir plus sur Structures dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by