MATLAB问题中的错误提示,怎么解决????

来源:百度知道 编辑:UC知道 时间:2024/09/20 11:45:02
% close all open figure window
close all
% create the mesh
[x,y]=meshgrid(linspace(-4,4,50));
% calculate z-values
z=3*x./(x.^2+y.^2+1);
% draw and label the contours
[c,h]=contour(x,y,z,10);
clabel(c,h,'manual')
% hold the plot
hold on
% labels and title
xlabel('x-axis')
ylabel('y-axis')
title('Level curves and gradient field of f(x,y) = 3x/(x^2 + y^2 + 1).')
% create the mesh locations for the gradient vectors
[x,y]=meshgrid(-4:.5:4);
% compute the gradient of F
Fx=(3*y.^2-3*x.^2+3)./(x.^2+y.^2+1).^2;
Fy=-6*x.*y./(x.^2+y.^2+1).^2;
% sketch the gradient field
quiver(x,y,Fx,Fy)
% turn on the grid
grid on
axis equal
??? Attempt to execute SCRIPT figure as a function.

Error in ==> gcf at 33
h = figure;

Error in ==> newplot at 61
fig = gcf;

Error in ==> contour at 64
cax =

你的上面的程序没有任何问题

不知道这是不是全部的程序

根据我的经验,你的问题是,在M脚本中加入了function函数

你只要在M文件的头部加上function matlabsky再运行就好了

%by dynamic
%see also http://www.matlabsky.com
%contact me matlabsky@gmail.com
%2009.2.
%

重装