Using GUIDE to Create checkboxes and save values to an Array
10 ビュー (過去 30 日間)
古いコメントを表示
I'm trying to use GUIDE to create checkboxes that, when selected, will place a 1 in an array, corresponding to cases that were selected. I would like to then use the array of selected cases for further processing.
I've tried creating the array two ways, listed below:
1) checkboxValue = get(handles.checkBox1, 'Value'); if checkboxValue==1 Subject(1,1)=1 end
2) a = get(hObject,'Value'); if a==1 Subject(1,1)=1 end
When I check a box using the first version, the program crashes. When I check a box using the second version, no array appears in the Workspace. How can I get the values to appear in an array?
Thank you.
0 件のコメント
回答 (2 件)
Azzi Abdelmalek
2013 年 1 月 15 日
編集済み: Azzi Abdelmalek
2013 年 1 月 15 日
If you want to see the value of Subject in workspace add
assignin('base','Subject',Subject)
0 件のコメント
Jan
2013 年 1 月 15 日
編集済み: Jan
2013 年 1 月 15 日
Please do not only mention, that the program crashes, but post the complete error message.
Of course the variable Subject is created in the workspace. But each function has its own workspace. Most likely you mean the base-workspace and yes, values written to a variable inside a function do not appear magically there. And this is fine. Better store the variables locally in the figure (see help guidata) and obtain it from there when you need it.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Structures についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!