24小时热门版块排行榜    

查看: 2805  |  回复: 1

zhaoxyah

铁杆木虫 (著名写手)

[求助] 用matlab解非线性方程组加for循环语句的问题已有1人参与

用matlab解非线性方程组,现在问题出在加for 循环语句上,想让其中一参数thita变化来求非线性方程组的解,但是for循环语句加进去之后循环不了,求指教,谢谢



function solve_noneqs2
clear all;clc
format long
x0=[0.8 -5 0.1];
[x fval]=fsolve(@objfun,x0)

function f=objfun(x)

for i=1:10:81

thita=i*3.14/180.0;
gam=0.8;
gama=gam/(cos(thita)+gam*(1-cos(thita)));  
nn=0;

mie=1836.0*4.0;
miu=1.0/mie;
tie=0.01;
rou=0.2;
uiy0=-0.01;
e0=-0.01;
f(1)=(1+x(1))*x(3)-(1-gama)*sqrt(2*mie*pi)*exp(x(2))/(1+erf(sqrt(-x(2))));
f(2)=gama*x(3)/(1-gama)-x(1)*sqrt(nn*nn-2*mie*x(2))/(1+x(1));
f(3)=(1+erf(sqrt(-x(2)))+2*exp(x(2)))/(1+erf(sqrt(-x(2))))...
+(-x(1)/(miu*nn*nn-2*x(2)))-(1-rou*uiy0*sin(thita)/e0)/(x(3)*x(3)-tie);
end
回复此楼

» 收录本帖的淘贴专辑推荐

材料学

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

月只蓝

主管区长 (职业作家)

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★
感谢参与,应助指数 +1
zhaoxyah: 金币+30, ★★★★★最佳答案 2015-01-28 14:35:23
CODE:
function solve_noneqs2
clear all;clc
format long
global thita
x0=[0.8 -5 0.1];
for i=1:10:81

thita=i*3.14/180.0;
[x fval]=fsolve(@objfun,x0)
end

function f=objfun(x)

global thita
gam=0.8;
gama=gam/(cos(thita)+gam*(1-cos(thita)));  
nn=0;

mie=1836.0*4.0;
miu=1.0/mie;
tie=0.01;
rou=0.2;
uiy0=-0.01;
e0=-0.01;
f(1)=(1+x(1))*x(3)-(1-gama)*sqrt(2*mie*pi)*exp(x(2))/(1+erf(sqrt(-x(2))));
f(2)=gama*x(3)/(1-gama)-x(1)*sqrt(nn*nn-2*mie*x(2))/(1+x(1));
f(3)=(1+erf(sqrt(-x(2)))+2*exp(x(2)))/(1+erf(sqrt(-x(2))))...
+(-x(1)/(miu*nn*nn-2*x(2)))-(1-rou*uiy0*sin(thita)/e0)/(x(3)*x(3)-tie);

计算结果:
CODE:
Equation solved.

fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.

<stopping criteria details>


x =

   0.018846681984329  -3.072831795928832   0.982314870246254


fval =

  1.0e-013 *

  -0.044408920985006   0.039968028886506  -0.595079541199084


Equation solved.

fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.

<stopping criteria details>


x =

   0.018855956779978  -3.075528224076973   0.965321046112058


fval =

  1.0e-013 *

  -0.004440892098501   0.004440892098501  -0.217603712826531


Equation solved.

fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.

<stopping criteria details>


x =

   0.019558737227657  -3.052541979758258   0.948120266395786


fval =

  1.0e-014 *

                   0  -0.355271367880050  -0.710542735760100


Equation solved.

fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.

<stopping criteria details>


x =

   0.021135332349230  -2.999752526247271   0.931165724462005


fval =

  1.0e-014 *

   0.044408920985006  -0.266453525910038  -0.177635683940025


Equation solved.

fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.

<stopping criteria details>


x =

   0.024008638352036  -2.909615150811957   0.914786597776324


fval =

  1.0e-015 *

   0.666133814775094  -0.888178419700125  -0.222044604925031


Equation solved.

fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.

<stopping criteria details>


x =

   0.029146638299003  -2.768619210304688   0.899037628244904


fval =

  1.0e-014 *

                   0  -0.177635683940025   0.022204460492503


Equation solved.

fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.

<stopping criteria details>


x =

   0.039085890345084  -2.550572682027647   0.883288524779719


fval =

  1.0e-015 *

  -0.222044604925031                   0   0.444089209850063


Equation solved.

fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.

<stopping criteria details>


x =

   0.062780505811200  -2.194272858045788   0.864731643692605


fval =

  1.0e-014 *

  -0.022204460492503   0.177635683940025                   0


Equation solved.

fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.

<stopping criteria details>


x =

   0.167507062022604  -1.476415003357842   0.830027082398914


fval =

  1.0e-015 *

  -0.111022302462516                   0   0.222044604925031

MATLAB、MS小问题、普通问题请发帖求助!时间精力有限,恕不接受无偿私信求助。
2楼2015-01-27 16:17:35
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 zhaoxyah 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[找工作] 初始合伙人来啦!(生物试剂耗材标准品) +3 欢快的小科研人 2024-06-15 6/300 2024-06-16 07:13 by 小李小李小李
[论文投稿] 投稿被一个审稿人恶意评审了怎么样? +5 1chen 2024-06-14 7/350 2024-06-15 23:15 by xy66xy
[教师之家] 每次骚扰女学生的都是院系领导,而不是普通教师,小编们要注意措辞正确 +7 zju2000 2024-06-15 9/450 2024-06-15 22:54 by zeolitess
[基金申请] Nature 11日发文,中国著名学者们称造假迫不得已 +5 babu2015 2024-06-14 5/250 2024-06-15 20:40 by lc231001
[硕博家园] 博士毕业高校和就业的相关问题 +4 SCITOPPP 2024-06-14 6/300 2024-06-15 18:54 by SCITOPPP
[考博] 希望能25博士入学,可提前一年做科研助理 +4 干饭版小太阳 2024-06-09 8/400 2024-06-15 18:36 by 独孤老狗
[基金申请] BO4的YQ答辩通知发布了吗? +6 博学笃行 2024-06-11 6/300 2024-06-15 16:04 by 悲催科研狗
[论文投稿] 求机械类四区sci推荐 5+3 迷茫小旷 2024-06-14 4/200 2024-06-15 11:25 by bobvan
[基金申请] 有没有机械的前辈分享一下评上海优都是什么成果啊 +7 wulala800 2024-06-10 7/350 2024-06-15 09:33 by 晓目崇
[食品] 食品博士导师 +6 小李醒yy 2024-06-11 9/450 2024-06-14 23:37 by 小李醒yy
[考研] 物理化学一对一辅导 +3 林大diao 2024-06-12 5/250 2024-06-14 20:57 by 林大diao
[基金申请] 化学会年会改成一年开一次了? +5 babu2015 2024-06-12 13/650 2024-06-14 10:46 by babu2015
[论文投稿] 最近写了一篇控制优化领域的文章,可以投哪里啊?有没有水一些的期刊推荐 +7 香瓜木香 2024-06-12 13/650 2024-06-14 07:05 by 香瓜木香
[基金申请] 工材E10口函评结束了吗 10+3 我1的飞翔 2024-06-13 5/250 2024-06-14 06:35 by nono2009
[论文投稿] 投稿后发现其他作者的邮箱填错了该怎么办呀 10+4 在飞的猪 2024-06-13 6/300 2024-06-14 04:45 by 小虫子咔咔
[有机交流] 旋蒸请教 +6 办公室摸鱼 2024-06-09 9/450 2024-06-13 21:31 by wuxiaominggo
[基金申请] 连续两年医学口青年项目初审体会 +11 进击的荣耀 2024-06-09 18/900 2024-06-13 17:27 by 进击的荣耀
[硕博家园] 科研求助 +5 杲www 2024-06-12 6/300 2024-06-13 16:16 by 姓李名明
[有机交流] 原料反应完了,怎么知道是产物还是中间体 +6 小胡在努力 2024-06-11 8/400 2024-06-13 13:33 by 091602
[硕博家园] 考博应该从哪里开始准备 +6 亮姐2019 2024-06-11 8/400 2024-06-13 12:53 by 帕秋莉GO
信息提示
请填处理意见