我正在尝试在 matlab 中编写一个可以求解二次方程的代码,但是我在第 41 行的代码的第一位出现错误。代码的最后一位只是计算 x 的值并通知用户如果这些值有复根或正态数
function quadraticsolver1
clc
clear all
fprintf ('Welcome to Quadratic Solver\n')
fprintf ('Created by Rémi Tuyaerts 2013\n')
% Get value for a
a=input('enter value for a ', 's');
% if value of a is empty or not numeric ask user to reenter it
while isempty(a); ischar(a);
disp ('The value entered for a is incorrect')
a=input('Please reenter value for a ', 's');
end
% Get value for b
b=input('enter value for b ', 's');
% if value of b is empty or not numeric ask user to reenter it
while isempty(b); ischar (b);
disp ('The value entered for b is incorrect')
b=input('Please reenter value for b', 's');
end
% Get value for c
c=input('enter value for c ', 's');
% if value of c is empty or not numeric ask user to reenter it
while isempty (c); ischar (c);
disp ('The value entered for a is incorrect')
c=input('Please reenter value for c ', 's');
end
% calculating the value of the sqrt
g = (b.^2)-(4*a.*c);
end