Azzera filtri
Azzera filtri

How to save checkbox values in an array?

8 visualizzazioni (ultimi 30 giorni)
Hi, this is the first time I use an userform at Matlab
I introduced there some checkboxes and I would like to save their values in an array at my code, something like:
Myarray = [checkbox1.value, checkbox2.value, ..., checkbox30.value]
It seems to be very simple, but I can't find an answer at internet :/
I'm using Matlab 2011

Risposta accettata

Marlon Saveri Silva
Marlon Saveri Silva il 18 Ago 2015
Modificato: Marlon Saveri Silva il 18 Ago 2015
Hi,
I've gotten a solution:
function checkbox1_Callback(hObject, eventdata, handles)
CheckBoxValue=get(handles.checkbox1,'Value');
if isequal(CheckBoxValue,1)
evalin('base', 'MyArray(1)=1;'); %Save "TRUE" in the array "MyArray()"
else
evalin('base', 'MyArray(1)=0;');
end
Then... I've just repet it for each checkbox. It's very strange MATLAB saves GUI variables in another workspace, when I couldn't get access.

Più risposte (0)

Categorie

Scopri di più su Get Started with MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by