how to extract and use the uicontrol from an cell array

2 次查看(过去 30 天)
I created 6 static texts with names: Reihenfolge1RealTime, Reihenfolge2RealTime,...
and now I want to make some of them invisible using:
set(handles.Reihenfolge3RealTime,'Visible','off');
set(handles.Reihenfolge4RealTime,'Visible','off');
set(handles.Reihenfolge5RealTime,'Visible','off');
set(handles.Reihenfolge6RealTime,'Visible','off');
In order to simplify and make these codes readable, I came up with an idea by using an cell array to store the above 6 uicontrols:
handles.ReihenfolgeRealTime = {handles.Reihenfolge1RealTime,handles.Reihenfolge2RealTime,...};
and also tried to use a ''for'' loop:
for i=3:1:size(handles.ReihenfolgeRealTime,2)
set(handles.ReihenfolgeRealTime(i),'Visible','off');
end
But by debugging the Matlab said :
Error using set
Conversion to double from cell is not possible.
Does anyone know how to solve this problem?

采纳的回答

Tommy
Tommy 2020-4-28
Indexing into a cell array with ( ) gives you another cell array. Use { } instead to access the data inside that cell array:
for i=3:1:size(handles.ReihenfolgeRealTime,2)
set(handles.ReihenfolgeRealTime{i},'Visible','off');
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by