필터 지우기
필터 지우기

How to save checkbox values in an array?

조회 수: 8 (최근 30일)
Marlon Saveri Silva
Marlon Saveri Silva 2015년 8월 14일
편집: Marlon Saveri Silva 2015년 8월 18일
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

채택된 답변

Marlon Saveri Silva
Marlon Saveri Silva 2015년 8월 18일
편집: Marlon Saveri Silva 2015년 8월 18일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by