How can I save string data as double in Userdata GUI?

I am working with radiobuttons in Matlab GUI. I want that everytime I press a radiobutton, a word stored in the UserData box prints using fprintf. I have the fprintf part figured out, however, I have been trying to save the words using the inspector UIcontrol window for every radiobutton but it doesn't work. Any help?
Thanks!

回答 (2 件)

Walter Roberson
Walter Roberson 2016 年 1 月 26 日

0 投票

At the MATLAB command line, take the string you want and double() it, such as
double('this is the first string')
The result will be a vector of numbers that you should be able to store.
Then when it comes time to fprintf() the userdata,
TheUserData = get(hObject, 'UserData');
fprintf('%s', char(TheUserData));
Nicolas Rodriguez
Nicolas Rodriguez 2016 年 5 月 10 日

0 投票

thank you very much, it worked!

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

質問済み:

2016 年 1 月 26 日

回答済み:

2016 年 5 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by