The pushbutton callback function below is from a GUI which uses thr quadratic fo
ID: 3695367 • Letter: T
Question
The pushbutton callback function below is from a GUI which uses thr quadratic formula to calculate the squareroots of a 2nd-order linear equation. (The quadiatic formula is: x = -b plusminus squareroot b^2 -4ac/2a) There are ERRORS in the code Please indicate and correct those coding errors %---Executes on button press m pushbutton1. function pushbutton 1_Callback(hObject eventdata handles) a = str2dbl(get(handles.edit1, String)); b = str2dbl(get(handles.edit2, String)); c = str2dbl(get(handles.edit3, String)); x1 = (-b + sqr(b^2 - 4*a*c))/2*a x2 = (-b - sqr(b^2 - 4*a*c))/2*a set (handles.text1, String,x1); set (handles.text2, String,x1);Explanation / Answer
1) str2dbl is wrong, correcr one is str2double
2) sqr is wrong sqrt is correct
3) Error in get( handles.edit1, String)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.