I wanna change the assigned value format's long in this function (value) "set(handles.edit1, 'String', value)"

1 回表示 (過去 30 日間)
%for example x=-0.134635523018792
%for gui presentation
set(handles.edit1, 'String', x)
%in gui x=-0.1346355 %7 numbers after the dot is appeared but I want to see whole numbers after the dot

採用された回答

Jan
Jan 2013 年 4 月 17 日
編集済み: Jan 2013 年 4 月 17 日
It is very surprising that
set(handles.edit1, 'String', x)
shows any string at all, when x is a double value. Actually only strings and cell strings are accepted.
This shows x with 16 digits:
x = -0.134635523018792;
set(handles.edit1, 'String', sprintf('%.16g', x))
Note that it cannot be guaranteed, that you see "all" digits, because there are no accurate decimal representations for the numbers, which are store in binary format internally. See also: FAQ: Why is 0.3-0.2-0.1 ~= 0
  4 件のコメント
Yao Li
Yao Li 2013 年 4 月 17 日
I noticed that he said your codes worked well just several minutes ago.
sermet
sermet 2013 年 4 月 17 日
ok no problem, it works thank you very much

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

その他の回答 (1 件)

Yao Li
Yao Li 2013 年 4 月 17 日
x='-0.134635523018792';
  4 件のコメント
Yao Li
Yao Li 2013 年 4 月 17 日
Actually, I tried the command on my computer just now and it works well. I don't know why you failed.
sermet
sermet 2013 年 4 月 17 日
ok no problem it works thank you so much

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

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by