Effacer les filtres
Effacer les filtres

how to extract and use the uicontrol from an cell array

3 vues (au cours des 30 derniers jours)
Dongyan Zhu
Dongyan Zhu le 28 Avr 2020
Commenté : Dongyan Zhu le 28 Avr 2020
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?

Réponse acceptée

Tommy
Tommy le 28 Avr 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
  1 commentaire
Dongyan Zhu
Dongyan Zhu le 28 Avr 2020
Thank you! That's what I am looking for:)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by