davidcheng 发表于 2006-4-4 08:32

各位牛人,小弟向你们请教。(MATLAB编程)

各位牛人,小弟不才,向你们请教。
以t 为自变量,w为函数的函数图像 (用MATLAB编程)
1256.659=w*100*sin(w*t)*(1+100*cos(w*t)/sqrt(300^2-(100*sin(w*t)).^2))
万分感谢!

happy 发表于 2006-4-4 10:04

这是一个隐函数画图问题,如果你用的matlab7.0可以用ezplot直接画

如果是matlab6.5或以下版本可以通过调用下面的函数实现
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 = 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])


%       A.Jutan UWO 2-2-98ajutan@julian.uwo.ca



if nargin == 1;% grid value and ranges not specified calculate default
      rangexy=[-2*pi,2*pi,-2*pi,2*pi];
   ngrid=50;
end


if nargin == 2;% grid value not specified
   ngrid=50;
end


% get 2-D grid for x and y


xm=linspace(rangexy(1),rangexy(2),ngrid);
ym=linspace(rangexy(3),rangexy(4),ngrid);
=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,,'b-');% plot single contour at f(x,y)=0, blue lines
xlabel('x');ylabel('y');
grid

cdwxg 发表于 2006-4-4 10:06

happy教授也实在太强了吧
能告诉我
有你不晓得的么?

yqchenlolo 发表于 2006-4-4 10:25

同佩服
好像happy教授是逢贴必答
牛人啊

handcart 发表于 2006-4-17 17:51

渐渐喜欢HAPPY教授了,真是天才
页: [1]
查看完整版本: 各位牛人,小弟向你们请教。(MATLAB编程)