Use of get function in the GUI (Graphic User Interface)

5 ビュー (過去 30 日間)
amey patil
amey patil 2012 年 4 月 16 日
Hello, I have a problem .I want to read data through a text box of GUI of matlab and this data happens to be in decimal and I want to convert into HEX data then I need to print that data in to text file in HEXADECIMAL format. This i m doing as below for get I m using following command tio read data from text box
X = get (hObject,'value');
then i m reading this value and converting it in to hex by following command
X1 = dec2hex (X);
then i am writing it to text file by following code
fprintf (fid, '%d ',X);
after doing this i should see result in text file but I m not able to see hex codes intead I m getting "0" answers.
Where is the problem.

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 4 月 16 日
Unless you need those character strings for some other reason, skip the dec2hex call and use
fprintf(fd, '%x ', X)
  2 件のコメント
amey patil
amey patil 2012 年 4 月 19 日
Thanks for the reply I did what u said but still it is giving answer as zero it is not working so now i feel that the problem is in get command.
Can U plz tell me what should be format for get command like if I want to read integer number ???
I have tried with strings but not it is reading it as character matrix of 1x3 size for 3 digit integer value..
Walter Roberson
Walter Roberson 2012 年 4 月 19 日
fprintf(fd, '%x ', sscanf('%d', get(hObject, 'value')))

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by