<>几天上不来,还以为账号被封了,Mathematica不是很熟悉,所以不能提供什么建议</P><>关于matlab中Implicit functi的直接命令,应该是其他人编的,具体从哪里下忘了具体网址</P><>我把文件输入,你另存为implot.m</P><P>function implot(fun,rangexy,ngrid)
% Implicit plot function
% function implot(fun,rangexy,ngrid)
% fun is 'inline' function f(x,y)=0 (Note function written as equal to zero)
% rangexy =[xmin,xmax,ymin,ymax] range over which x and y is ploted default(-2*pi,2*pi)
% ngrid is the number of grid points used to calculate the plot,
% Start with course grid (ngrid =20) and then use finer grid if necessary
% default ngrid=50
%
% Example
% Plot y^3+exp(y)-tanh(x)=0
%
% write function f as an 'inline' function of x and y-- right hand side
% equal to zero
%
% f=inline('y^3+exp(y)-tanh(x)','x','y')
% implot(f,[-3 3 -2 1])</P><P>
% A.Jutan UWO 2-2-98 <a href="mailtajutan@julian.uwo.ca" target="_blank" >ajutan@julian.uwo.ca</A></P><P>if nargin == 1 ;% grid value and ranges not specified calculate default
rangexy=[-2*pi,2*pi,-2*pi,2*pi];
ngrid=50;
end</P><P>
if nargin == 2; % grid value not specified
ngrid=50;
end</P><P>
% get 2-D grid for x and y</P><P>
xm=linspace(rangexy(1),rangexy(2),ngrid);
ym=linspace(rangexy(3),rangexy(4),ngrid);
[x,y]=meshgrid(xm,ym);
fvector=vectorize(fun);% vectorize the inline function to handle vectors of x y
fvalues=feval(fvector,x,y); %calculate with feval-this works if fvector is an m file too
%fvalues=fvector(x,y); % can also calculate directly from the vectorized inline function
contour(x,y,fvalues,[0,0],'b-');% plot single contour at f(x,y)=0, blue lines
xlabel('x');ylabel('y');
grid
</P> |