如何使用MATLAB从gui获取抛物线的参数来绘制抛物线
我试着这样做: 我找到了这个,并尝试这样使用它:如何使用MATLAB从gui获取抛物线的参数来绘制抛物线,matlab,plot,matlab-guide,Matlab,Plot,Matlab Guide,我试着这样做: 我找到了这个,并尝试这样使用它: 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); 但是我不断收到错误…
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);
但是我不断收到错误…如果您定义变量
xLine
,但在yToPlot
中使用变量x
,我们将不胜感激。这就是为什么会出现这样一个错误:未定义x
。在yToPlot
中,您还有b.x
。然后,MATLAB认为b
是一个结构,您希望访问b
中名为x
的字段。由于b
不是结构,并且没有字段x
,因此会出现错误“尝试引用非结构数组的字段”。如果您解决了这两个问题,根据您给出的代码,它应该可以工作:
xLine=[(-b)/2*a-5:0.01:(-b)/2*a+5];
yToPlot= a*xLine.^2 + b*xLine+c;
plot(xLine,yToPlot);