简体   繁体   English

执行八度程序时出现未定义的错误

[英]Undefined error while executing octave program

While executing the plotdata file in octave I'm getting the following error:在八度执行 plotdata 文件时,出现以下错误:

plotData error: 'x' undefined near line 7 column 6 error: called from plotData at line 7 column 1 plotData error: 'y' undefined near line 7 column 6 error: called from plotData at line 7 column 1 plotData 错误:第 7 行第 6 列附近的“x”未定义错误:从第 7 行第 1 列的 plotData 调用 plotData 错误:第 7 行第 6 列附近的“y”未定义错误:从第 7 行第 1 列的 plotData 调用

My code:我的代码:

function plotData(x, y)

figure;

plot(x,y,'rx','MarkerSize',10);

ylabel('Profit in $10,000s');

xlabel('Population of city in 10,000s');

end

plotData expects ax and y value to be provided when running. plotData 期望在运行时提供 ax 和 y 值。

if you press the run button on the GUI you aren't giving it an e, y value.如果你按下 GUI 上的运行按钮,你并没有给它一个 e,y 值。

Likewise if you run as 'plotData' in the console window, you aren't giving an x,y value同样,如果您在控制台 window 中以 'plotData' 运行,则不会给出 x,y 值

In both cases, no x,y value means that x and y variables have not been defined in the function and so the error occurs.在这两种情况下,没有 x,y 值意味着 x 和 y 变量尚未在 function 中定义,因此会发生错误。

If you ran as:如果你运行为:

plotData(10,20)

You would not have the error occur as ax,y value is being provided.当提供 ax,y 值时,您不会发生错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM