フィルターのクリア

NaN error when trying to display calculation result

1 回表示 (過去 30 日間)
Oliver Ferenczi
Oliver Ferenczi 2019 年 11 月 4 日
回答済み: JESUS DAVID ARIZA ROYETH 2019 年 11 月 4 日
Hi,
When I try to run this code, the static text always says NaN?
I enter numbers for a, b and c. Then i try to do some calculations with these values and then try to display the answer "discriminant_string" in the static text box called Result_Text.
Why does it give me this result?
I'm using Matlab GUIDE for the GUI
Here is the code
a = get(handles.A_Value,'String');
b = get(handles.B_Value,'String');
c = get(handles.C_Value,'String');
p1 = str2double(b) * str2double(b);
p2 = str2double(a) * str2double(c) * 4;
discriminant = str2double(p1) * str2double(p2);
discriminant_string = num2str(discriminant);
set(handles.Result_Text,'String',discriminant_string);
Thank you very much, im just starting out :)
  1 件のコメント
Oliver Ferenczi
Oliver Ferenczi 2019 年 11 月 4 日
Im using the Matlab Guide for the GUI

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

採用された回答

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH 2019 年 11 月 4 日
solution:
a = get(handles.A_Value,'String');
b = get(handles.B_Value,'String');
c = get(handles.C_Value,'String');
p1 = str2double(b) * str2double(b);
p2 = str2double(a) * str2double(c) * 4;
discriminant = p1 * p2;
discriminant_string = num2str(discriminant);
set(handles.Result_Text,'String',discriminant_string);

その他の回答 (0 件)

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by