I am trying to edit an old code to simplify it but I keep getting errors. Right now I am getting the script name error even though I have followed instructions fo rnaming
I get the error saying i can’t have the same script name as the function but it worked before and I haven’t changed the name
%% problem 1c – projectile Quadratic
function [root] = Quadratic(a, b, c, plusOrMinus)
% Quadratic – determine the root of the projectile using the quadratic equation
% a, b, and c are the coefficients of the quadratic equation, plusOrMinus
% is a multiplier (+1 or -1) that selects the + or – in the quadratic
% formula. root is a single root of the quadratic equation that is
% computed using the quadratic formula.
% Erin Gibbs, u1556567, ME EN 1010, HW#2
root = (-b + plusOrMinus * (sqrt(b^2 – (4*a*c)))) / (2 * a);
end
%% test case 1 (positive plusOrMinus)
% equation: x^2 – x – 2 = 0
a = 1;
b = -1;
c = -2;
plusOrMinus = 1;
[root] = Quadratic(a, b, c, plusOrMinus)I get the error saying i can’t have the same script name as the function but it worked before and I haven’t changed the name
%% problem 1c – projectile Quadratic
function [root] = Quadratic(a, b, c, plusOrMinus)
% Quadratic – determine the root of the projectile using the quadratic equation
% a, b, and c are the coefficients of the quadratic equation, plusOrMinus
% is a multiplier (+1 or -1) that selects the + or – in the quadratic
% formula. root is a single root of the quadratic equation that is
% computed using the quadratic formula.
% Erin Gibbs, u1556567, ME EN 1010, HW#2
root = (-b + plusOrMinus * (sqrt(b^2 – (4*a*c)))) / (2 * a);
end
%% test case 1 (positive plusOrMinus)
% equation: x^2 – x – 2 = 0
a = 1;
b = -1;
c = -2;
plusOrMinus = 1;
[root] = Quadratic(a, b, c, plusOrMinus) I get the error saying i can’t have the same script name as the function but it worked before and I haven’t changed the name
%% problem 1c – projectile Quadratic
function [root] = Quadratic(a, b, c, plusOrMinus)
% Quadratic – determine the root of the projectile using the quadratic equation
% a, b, and c are the coefficients of the quadratic equation, plusOrMinus
% is a multiplier (+1 or -1) that selects the + or – in the quadratic
% formula. root is a single root of the quadratic equation that is
% computed using the quadratic formula.
% Erin Gibbs, u1556567, ME EN 1010, HW#2
root = (-b + plusOrMinus * (sqrt(b^2 – (4*a*c)))) / (2 * a);
end
%% test case 1 (positive plusOrMinus)
% equation: x^2 – x – 2 = 0
a = 1;
b = -1;
c = -2;
plusOrMinus = 1;
[root] = Quadratic(a, b, c, plusOrMinus) arduino, function, script name MATLAB Answers — New Questions