How to switch show between 2 static text in matlab GUI

1 Ansicht (letzte 30 Tage)
Adisorn Phanukthong
Adisorn Phanukthong am 9 Jun. 2017
Kommentiert: Jan am 19 Jun. 2017
hide A and show N ,hide N and show A
  3 Kommentare
Adisorn Phanukthong
Adisorn Phanukthong am 13 Jun. 2017
if cellfun(@(x)x == 'A',status)
set(handles.texta,'visible','on');
set(handles.textn,'visible','off');
else
set(handles.textn,'visible','on');
set(handles.texta,'visible','off');
end
right?
Adam
Adam am 13 Jun. 2017
I don't know what your exact code is that needs this, but you shouldn't need anything complicated like a cellfun, but you never really stated what the trigger is for changing the visible status.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Jan
Jan am 9 Jun. 2017
Either change the String and Color property of one text object. Or set the 'Visible' property of one to 'on' and the other to 'off'.
  2 Kommentare
Adisorn Phanukthong
Adisorn Phanukthong am 13 Jun. 2017
if cellfun(@(x)x == 'A',status)
set(handles.texta,'visible','on');
set(handles.textn,'visible','off');
else
set(handles.textn,'visible','on');
set(handles.texta,'visible','off');
end
right?
Jan
Jan am 19 Jun. 2017
Perhaps: if any(strcmp(status, 'A')) is simpler as the cellfun approach. If your code works, it is right. Does it work?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by