声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1426|回复: 4

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

[复制链接]
发表于 2006-4-4 08:32 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

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

使用道具 举报

发表于 2006-4-4 10:04 | 显示全部楼层
这是一个隐函数画图问题,如果你用的matlab7.0可以用ezplot直接画

如果是matlab6.5或以下版本可以通过调用下面的函数实现
  1. function implot(fun,rangexy,ngrid)
  2. % Implicit plot function
  3. % function implot(fun,rangexy,ngrid)
  4. % fun is 'inline' function f(x,y)=0 (Note function written as equal to zero)
  5. % rangexy =[xmin,xmax,ymin,ymax] range over which x and y is ploted default(-2*pi,2*pi)
  6. % ngrid is the number of grid points used to calculate the plot,
  7. % Start with course grid (ngrid =20) and then use finer grid if necessary
  8. % default ngrid=50
  9. %
  10. % Example
  11. % Plot y^3+exp(y)-tanh(x)=0
  12. %
  13. % write function f as an 'inline' function of x and y-- right hand side
  14. % equal to zero
  15. %
  16. % f=inline('y^3+exp(y)-tanh(x)','x','y')
  17. % implot(f,[-3 3 -2 1])


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



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


  23. if nargin == 2;  % grid value not specified
  24.    ngrid=50;
  25. end


  26. % get 2-D grid for x and y


  27. xm=linspace(rangexy(1),rangexy(2),ngrid);
  28. ym=linspace(rangexy(3),rangexy(4),ngrid);
  29. [x,y]=meshgrid(xm,ym);
  30. fvector=vectorize(fun);% vectorize the inline function to handle vectors of x y
  31. fvalues=feval(fvector,x,y); %calculate with feval-this works if fvector is an m file too
  32. %fvalues=fvector(x,y); % can also calculate directly from the vectorized inline function
  33. contour(x,y,fvalues,[0,0],'b-');% plot single contour at f(x,y)=0, blue lines
  34. xlabel('x');ylabel('y');
  35. grid
复制代码
发表于 2006-4-4 10:06 | 显示全部楼层
happy教授也实在太强了吧
能告诉我
有你不晓得的么?
发表于 2006-4-4 10:25 | 显示全部楼层
同佩服
好像happy教授是逢贴必答
牛人啊
发表于 2006-4-17 17:51 | 显示全部楼层
渐渐喜欢HAPPY教授了,真是天才
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-6-6 23:33 , Processed in 0.061482 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表