MATLAB Answers

Call several handles with the same name

2 views (last 30 days)
Birch
Birch on 8 Sep 2017
Edited: Stephen Cobeldick on 8 Sep 2017
I need a bit of help. I have 40 handels called handles.rgb1-handles.rgb40. Is it possible to call all of them without calling them one at the time?

  1 Comment

Stephen Cobeldick
Stephen Cobeldick on 8 Sep 2017
Next time use a non-scalar structure rather then putting an index into the fieldnames. Then your code will be a lot simpler.

Sign in to comment.

Answers (1)

OCDER
OCDER on 8 Sep 2017
Edited: OCDER on 8 Sep 2017
I think dynamic field names are what you want to use.
for j = 1:40
ThisHandle = handles.(['rgb' num2str(j)]); %Use dynamic field names
%Do something with ThisHandle
end

  0 Comments

Sign in to comment.

Tags

Products


Translated by