找回密码
 注册
Simdroid-非首页
楼主: taxsh

隐函数方程的求解[有代码]

[复制链接]
发表于 2010-4-26 16:01:06 | 显示全部楼层 来自 山东青岛
20# zuobinjstu A=90,B也应该是90左右波动,我经行了运动仿真,B根据beta角度不同的仿真图形如附件。我想用公式理论验证下

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
回复 不支持

使用道具 举报

发表于 2010-4-26 23:50:42 | 显示全部楼层 来自 北京
Simdroid开发平台

  1. B = @(t) fzero(@(B) (r*sin(A)-rho*sin(3*B))*(cos(beta)-sin(beta)*sin(theta)*cos(3*B)-...
  2. sin(beta)*sin(3*B)*tan(B)*sin(theta))-(r*cos(A)-rho*cos(beta)*cos(3*B)+...
  3. rho*sin(beta)*sin(theta))*tan(B)*cos(theta) ,90);
复制代码
改为

  1. B = @(t) fzero(@(B) (r*sin(90*t)-rho*sin(3*B))*(cos(beta)-sin(beta)*sin(theta)*cos(3*B)-...
  2. sin(beta)*sin(3*B)*tan(B)*sin(theta))-(r*cos(90*t)-rho*cos(beta)*cos(3*B)+...
  3. rho*sin(beta)*sin(theta))*tan(B)*cos(theta) ,90);
复制代码
就可以了。关于如何改变此程序中beta值,整段代码做成函数形式,接受bete输入,out = arrayfun(@(T) dBt(T),t); out作为对应beta值的输出,这样对应不同的beta得到不同的out,然后画图就OK了。

评分

1

查看全部评分

回复 不支持

使用道具 举报

发表于 2010-4-27 08:44:22 | 显示全部楼层 来自 山东青岛
22# rocwoods 谢谢你的多次帮忙,让我受益匪浅。也感谢这个论坛有这么多的热心朋友的帮助。你也一定很忙吧!那么晚了还回复我,我很感谢!rocwoods如果可以,可以加我为好久嘛?我的邮箱:[email=zuobinjstu@163.com, QQ:354637093]zuobinjstu@163.com, QQ:354637093[/email]
回复 不支持

使用道具 举报

发表于 2010-4-28 10:30:21 | 显示全部楼层 来自 山东青岛
本帖最后由 zuobinjstu 于 2010-4-28 10:41 编辑

22# rocwoods
我运行出来图像了,可让我纳闷的是,这个图像和理论所要的图像完全不一样,不知道怎么回事。我的导师曾经将那个公式用手算化简出来然后汇出的图像应该在90左右,(见20楼附件而我运行出来图像完全不一样,我在想难道是程序哪里有偏差还是matlab运算图像的算法不一样。还请你帮忙看下,谢谢!
代码如下是为了算这个:
当(r*sin(90*t)-rho*sin(3*B)*cos(theta))*(cos(beta)-sin(beta)*sin(theta)*cos(3*B)*cos(theta)-...

sin(beta)*sin(3*B)*tan(B)*sin(theta))-(r*cos(90*t)-rho*cos(beta)*cos(3*B)+...

rho*sin(beta)*sin(theta))*tan(B)*cos(theta)=0时, B的一阶导数关于t的图像(应该是90左右)
参照你的代码如下:
syms A B ;


r=37;L=140.5;beta=pi/18;


rho=r/2*(1/cos(beta)-1);


theta=asin(rho/L);

f=(r*sin(A)-rho*sin(3*B)*cos(theta))*(cos(beta)-sin(beta)*sin(theta)*cos(3*B)*cos(theta)-...

sin(beta)*sin(3*B)*tan(B)*sin(theta))-(r*cos(A)-rho*cos(beta)*cos(3*B)+...

rho*sin(beta)*sin(theta))*tan(B)*cos(theta);


F = subs(f,{
'A','B'},{'90*t','B(t)'});

dFt = diff(F,'t');

dFt = subs(dFt,'diff(B(t), t)','dBt');


dBt = solve(dFt,
'dBt');

B = @(t) fzero(@(B) (r*sin(90*t)-rho*sin(3*B)*cos(theta))*(cos(beta)-...


sin(beta)*sin(theta)*cos(3*B)*cos(theta)-
...

sin(beta)*sin(3*B)*tan(B)*sin(theta))-(r*cos(90*t)-rho*cos(beta)*cos(3*B)+...

rho*sin(beta)*sin(theta))*tan(B)*cos(theta) ,90);

eval(['dBt = @(t) ',char(dBt),';' ])

t = 0:0.5:12;

plot(t,arrayfun(@(T) dBt(T),t) )

回复 不支持

使用道具 举报

发表于 2010-4-28 20:25:04 | 显示全部楼层 来自 广东
本帖最后由 rocwoods 于 2010-4-28 20:26 编辑

你这个问题原因在于方程是高频振荡方程,有多个解。而fzero求解只能求出一个解,fzero求解速度非常快,但是不能保证求得的解在初始点附近,因此出现了有些解远离90的情况。只能退而求其次用fsolve替换fzero,fsolve本来是用来求多元非线性方程的解的,给定初始值,一般求出的解不会脱离初值太远,但是速度比较慢。修改后代码如下:

  1. syms A B ;
  2. r=37;L=140.5;beta=pi/18;
  3. rho=r/2*(1/cos(beta)-1);
  4. theta=asin(rho/L);
  5. f=(r*sin(A)-rho*sin(3*B)*cos(theta))*(cos(beta)-sin(beta)*sin(theta)*cos(3*B)*cos(theta)-...
  6. sin(beta)*sin(3*B)*tan(B)*sin(theta))-(r*cos(A)-rho*cos(beta)*cos(3*B)+...
  7. rho*sin(beta)*sin(theta))*tan(B)*cos(theta);
  8. F = subs(f,{'A','B'},{'90*t','B(t)'});
  9. dFt = diff(F,'t');
  10. dFt = subs(dFt,'diff(B(t), t)','dBt');
  11. dBt = solve(dFt,'dBt');

  12. options = optimset('TolFun',1e-12,'display','off');
  13. B = @(t) fsolve(@(B) (r*sin(90*t)-rho*sin(3*B)*cos(theta)).*(cos(beta)-...
  14. sin(beta)*sin(theta)*cos(3*B)*cos(theta)-...
  15. sin(beta)*sin(3*B).*tan(B)*sin(theta))-(r*cos(90*t)-rho*cos(beta)*cos(3*B)+...
  16. rho*sin(beta)*sin(theta)).*tan(B)*cos(theta) ,90,options);

  17. eval(['dBt = @(t) ',char(dBt),';' ])
  18. t = 0:0.5:12;
  19. plot(t,arrayfun(@(T) dBt(T),t) )
复制代码
如果还是不符合预期,试着从你专业角度入手,看看方程可以怎样简化或者变形,使得方程的解能够限制在可控的范围内。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×

评分

1

查看全部评分

回复 不支持

使用道具 举报

发表于 2010-4-29 15:15:22 | 显示全部楼层 来自 山东青岛
本帖最后由 zuobinjstu 于 2010-4-29 15:20 编辑

25# rocwoods 恩,这个图像是比fzero好多了,我需要的图像是在在90之间微微波动,很显然还需要在处理。那个f函数是这个,我们输入到matlab里的表达式:
  • f=(r*sin(A)-rho*sin(3*B)*cos(theta))*(cos(beta)-sin(beta)*sin(theta)*cos(3*B)*cos(theta)-...
  • sin(beta)*sin(3*B)*tan(B)*sin(theta))-(r*cos(A)-rho*cos(beta)*cos(3*B)+...
  • rho*sin(beta)*sin(theta))*tan(B)*cos(theta)与下图是一样的吧

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
回复 不支持

使用道具 举报

发表于 2010-4-29 15:22:47 | 显示全部楼层 来自 山东青岛
25# rocwoods 好像很难根据目前的表达式求出以下附件的图形。90左右微微波动

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
回复 不支持

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Simapps系列直播

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-10-7 01:26 , Processed in 0.041652 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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