声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2317|回复: 4

[编程技巧] 求助:怎么用matlab求解联立方程组啊

[复制链接]
发表于 2009-8-14 22:34 | 显示全部楼层 |阅读模式

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

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

x
求助:急用:我想用matlab求解两个方程p1和Mcr,这两个方程里含有两个未知数x和gama,其他都是已知的值。我用了solve,可是结果总是显示empty空值,不知道是什么原因。望高手们能给以指点啊,我附上源程序,希望帮我解决一下这个问题了!谢谢了!
这里面的两个方程就是p1和Mcr让它们为零就可以了。
  1. clc;clear;
  2. syms gama ftk x
  3. %x=685.2076;
  4. %gama=1.0;
  5. N=1600000; As=763; As1=66; b=115; hw=1000;
  6. %Mcr=6E8;
  7. Es=200000; Ec=38000; ftk=4.42; epsilontu=120.2E-6;
  8. %ftk=Ec*epsilontu/gama;
  9. phy=epsilontu/(hw-x);
  10. as=((990-x)*339*10+(930-x)*226*70+(870-x)*66*130+(810-x)*66*190+(750-x)*66*250)/((990-x)*339+(930-x)*226+(870-x)*66+(810-x)*66+(750-x)*66)
  11. epsilons=(hw-as-x)*phy; epsilons1=(650-x)*phy;
  12. sigmas=Es*phy*(hw-as-x); sigmas1=epsilons1*Es;
  13. Tc=0.5*gama*ftk*(hw-x)*b, Ts=Es*phy*(hw-as-x)*As, Ts1=sigmas1*As1
  14. asp=as;
  15. Asp=763; As1p=66; As2p=66; As3p=66;
  16. epsilonsp=(x-asp)*phy; epsilons1p=phy*(x-350); epsilons2p=phy*(x-450); epsilons3p=phy*(x-550);
  17. sigmasp=epsilonsp*Es; sigmas1p=Es*epsilons1p; sigmas2p=Es*epsilons2p; sigmas3p=Es*epsilons3p;
  18. Tsp=(x-asp)*phy*Asp*Es, Cc=x*x*gama*ftk/(2*(hw-x))*b
  19. Ts1p=sigmas1p*As1p, Ts2p=sigmas2p*As2p, Ts3p=sigmas3p*As3p

  20. %p1=N+Tc+Ts-Tsp-Cc
  21. p1=N+Tc+Ts+Ts1-Tsp-Cc-Ts1p-Ts2p-Ts3p
  22. %p1=1600000+7.072*(1000-x)+(1.346e8*(1000-as-x)+13200000*(650-x)-134600000*(x-asp)-13200000*(x-350)-13200000*(x-450)-13200000*(x-550))*120.2e-6/(1000-x)-7.072*x^2/(1000-x)
  23. %solve('N+Tc+Ts+Ts1-Tsp-Cc-Ts1p-Ts2p-Ts3p=0','x')
  24. Mcr=Ts*(hw/2-as)+Tc*(hw/2-(hw-x)/3)+Ts1*150-Ts1p*50+Ts2p*50+Ts3p*150+Tsp*(hw/2-asp)+Cc*(hw/2-x/3)
复制代码

[ 本帖最后由 ChaChing 于 2009-8-14 23:01 编辑 ]
回复
分享到:

使用道具 举报

发表于 2009-8-15 01:08 | 显示全部楼层

时间有限, 无法细看LZ的程序! sorry
两个方程两个未知数, 不就是典型的Ax=b ?
为何一定要用symbolic不能用数值解吗?  ==> x=A\b
 楼主| 发表于 2009-8-15 10:29 | 显示全部楼层

回复 板凳 ChaChing 的帖子

主要是那两个方程里面同时含有x和gama两个变量,很长的式子。我没办法把它化简成那种很明显的形式。
p1=(14291182625542246875*(x - 350))/(9007199254740992*(x - 1000)) + (14291182625542246875*(x - 450))/(9007199254740992*(x - 1000)) + (14291182625542246875*(x - 550))/(9007199254740992*(x - 1000)) + (14291182625542246875*(x - 650))/(9007199254740992*(x - 1000)) + (330429464948143465625*(x - (56830*x - 48065700)/(763*x - 706170)))/(18014398509481984*(x - 1000)) + (330429464948143465625*(x + (56830*x - 48065700)/(763*x - 706170) - 1000))/(18014398509481984*(x - 1000)) - (5083*gama*(x - 1000))/20 + (5083*gama*x^2)/(10*(2*x - 2000)) + 1600000
Mcr=(357279565638556171875*(x - 350))/(4503599627370496*(x - 1000)) - (357279565638556171875*(x - 450))/(4503599627370496*(x - 1000)) - (1071838696915668515625*(x - 550))/(4503599627370496*(x - 1000)) + (1071838696915668515625*(x - 650))/(4503599627370496*(x - 1000)) + (330429464948143465625*(x - (56830*x - 48065700)/(763*x - 706170))*((56830*x - 48065700)/(763*x - 706170) - 500))/(18014398509481984*(x - 1000)) - (330429464948143465625*((56830*x - 48065700)/(763*x - 706170) - 500)*(x + (56830*x - 48065700)/(763*x - 706170) - 1000))/(18014398509481984*(x - 1000)) - (5083*gama*(x/3 + 500/3)*(x - 1000))/20 + (5083*gama*x^2*(x/3 - 500))/(10*(2*x - 2000))
这是最后的两个方程。怎么解啊?
发表于 2009-8-15 10:55 | 显示全部楼层
[gamaSol,xSol]=solve(p1,Mcr,'x','gama')

评分

1

查看全部评分

发表于 2009-8-15 10:58 | 显示全部楼层
  1. clc
  2. clear
  3. syms x gama
  4. p1=(14291182625542246875*(x - 350))/(9007199254740992*(x - 1000)) + ...
  5. (14291182625542246875*(x - 450))/(9007199254740992*(x - 1000)) + ...
  6. (14291182625542246875*(x - 550))/(9007199254740992*(x - 1000)) + ...
  7. (14291182625542246875*(x - 650))/(9007199254740992*(x - 1000)) + ...
  8. (330429464948143465625*(x - (56830*x - 48065700)/(763*x - 706170)))/(18014398509481984*(x - 1000)) + ...
  9. (330429464948143465625*(x + (56830*x - 48065700)/(763*x - 706170) - 1000))/(18014398509481984*(x - 1000)) -...
  10. (5083*gama*(x - 1000))/20 + (5083*gama*x^2)/(10*(2*x - 2000)) + 1600000;
  11. Mcr=(357279565638556171875*(x - 350))/(4503599627370496*(x - 1000)) - ...
  12. (357279565638556171875*(x - 450))/(4503599627370496*(x - 1000)) - ...
  13. (1071838696915668515625*(x - 550))/(4503599627370496*(x - 1000)) + ...
  14. (1071838696915668515625*(x - 650))/(4503599627370496*(x - 1000)) + ...
  15. (330429464948143465625*(x - (56830*x - 48065700)/(763*x - 706170))*((56830*x - 48065700)/...
  16. (763*x - 706170) - 500))/(18014398509481984*(x - 1000)) - ...
  17. (330429464948143465625*((56830*x - 48065700)/(763*x - 706170) - 500)*(x + ...
  18. (56830*x - 48065700)/(763*x - 706170) - 1000))/(18014398509481984*(x - 1000)) - ...
  19. (5083*gama*(x/3 + 500/3)*(x - 1000))/20 + (5083*gama*x^2*(x/3 - 500))/(10*(2*x - 2000));
  20. y=solve(p1,Mcr)
复制代码

>> vpa(y.gama,3)

ans =

         -.2
.5-.56e-1*i
.5+.56e-1*i


>> vpa(y.x,3)

ans =

      .100e4
929.+6.55*i
929.-6.55*i

评分

1

查看全部评分

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-11-18 22:20 , Processed in 0.139568 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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