how to extract and use the uicontrol from an cell array
2 views (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
Tommy
on 28 Apr 2020
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
More Answers (0)
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!