-1

I've tried to do it like this:

I've found this https://www.quora.com/How-do-I-draw-a-parabola-in-MATLAB and tried to use it like that:

a=str2double(get(handles.InputA,'string'));
b=str2double(get(handles.InputB,'string'));
c=str2double(get(handles.InputC,'string'));
xLine=[(-b)/2*a-5:0.01:(-b)/2*a+5];
yToPlot= a*x.^2 + b.x+c;
plot(xLine,yToPlot);

but I keep getting errors...any help would be appreciated

Liana78
  • 25
  • 6

1 Answers1

0

You define the variable xLine, but use the variable x in yToPlot. That's why you get an error saying x is not defined. Also in yToPlot you have b.x. MATLAB then thinks that b is a struct and that you want to access the field named x of b. Since b is not a struct, and doesn't have a field x, you'll get the error 'Attempt to reference field of non-structure array.'. If you fix these two, it should work, according to the code you've given:

xLine=[(-b)/2*a-5:0.01:(-b)/2*a+5];
yToPlot= a*xLine.^2 + b*xLine+c;
plot(xLine,yToPlot);
ViG
  • 1,848
  • 1
  • 11
  • 13