请问这个matlab CODE哪里有问题?刚学MATLAB
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/11 08:34:20
请问这个matlab CODE哪里有问题?刚学MATLAB
多谢.function [output] = func(x,y)output = x.^2 + y.^2;x = 0.0:pi/10:pi;y = x;[X,Y] = meshgrid(x,y);f = func(X,Y);contour(X,Y,f)axis([0 pi 0 pi])axis equal我是把这个用editor写的东西存为func.m, 运行.报错是:funcError using func (line 2)Not enough input arguments.后来我单独把function [output] = func(x,y)output = x.^2 + y.^2;存成func.m, 然后把剩下的x = 0.0:pi/10:pi;y = x;[X,Y] = meshgrid(x,y);f = func(X,Y);contour(X,Y,f)axis([0 pi 0 pi])axis equal在同一个目录下存成contours.m,运行后出错:Attempt to execute SCRIPT contours as a function:D:\m files\contours.mError in specgraph.contourgroup/refresh (line 180) [this.contourmatrix,msg] = contours(x,y,z,levels);Error in specgraph.contourgroup/schema>LdoDirtyAction (line 265) refresh(h);Warning: Error occurred while evaluating listener callback.> In contour at 95 In contours at 5请问哪里有问题,刚学matlab 一头雾水.
多谢.function [output] = func(x,y)output = x.^2 + y.^2;x = 0.0:pi/10:pi;y = x;[X,Y] = meshgrid(x,y);f = func(X,Y);contour(X,Y,f)axis([0 pi 0 pi])axis equal我是把这个用editor写的东西存为func.m, 运行.报错是:funcError using func (line 2)Not enough input arguments.后来我单独把function [output] = func(x,y)output = x.^2 + y.^2;存成func.m, 然后把剩下的x = 0.0:pi/10:pi;y = x;[X,Y] = meshgrid(x,y);f = func(X,Y);contour(X,Y,f)axis([0 pi 0 pi])axis equal在同一个目录下存成contours.m,运行后出错:Attempt to execute SCRIPT contours as a function:D:\m files\contours.mError in specgraph.contourgroup/refresh (line 180) [this.contourmatrix,msg] = contours(x,y,z,levels);Error in specgraph.contourgroup/schema>LdoDirtyAction (line 265) refresh(h);Warning: Error occurred while evaluating listener callback.> In contour at 95 In contours at 5请问哪里有问题,刚学matlab 一头雾水.
function [output] = func(x,y)output = x.^2 + y.^2;end这个保存为func.m文件下面的这些作为主程序,我调试的时候没有问题啊x = 0.0:pi/10:pi;y = x;[X,Y] = meshgrid(x,y);f = func(X,Y);contour(X,Y,f)axis([0 pi 0 pi])axis equal 查看原帖