フィルターのクリア

Guide: How to save popup menu value in a text file

1 回表示 (過去 30 日間)
monmatlab
monmatlab 2016 年 12 月 16 日
コメント済み: monmatlab 2016 年 12 月 16 日
Hey, I have a popup menu with two options (m , f) Now I want to save the chosen option of the user in a text file when pressed the pushbutton.
function pushbutton1_Callback(hObject, eventdata, handles)
fid = fopen('Subject.txt','wt');
fprintf(fid,'%c',get(handles.popupmenu2,'Value'));
fclose(fid);
For the first option I get a Square and for the second option it does not save anything in the file.
Is there something I am missing?

採用された回答

Adam
Adam 2016 年 12 月 16 日
If you want to save the value (i.e. 1 or 2) then you need:
%i or %d
rather than %c. If you want the string then you need something more like
str = get(handles.popupmenu2,'String')
fprintf(fid,'%s', str{ get(handles.popupmenu2,'Value') });

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by