Info

此问题已关闭。 请重新打开它进行编辑或回答。

Call several handles with the same name

1 次查看(过去 30 天)
Birch
Birch 2017-9-8
关闭: MATLAB Answer Bot 2021-8-20
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 个评论
Stephen23
Stephen23 2017-9-8
编辑:Stephen23 2017-9-8
Next time use a non-scalar structure rather then putting an index into the fieldnames. Then your code will be a lot simpler.

回答(1 个)

OCDER
OCDER 2017-9-8
编辑:OCDER 2017-9-8
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

此问题已关闭。

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by