필터 지우기
필터 지우기

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 :)

채택된 답변

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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by