24小时热门版块排行榜    

查看: 3021  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[博后之家] 广西大学-广州大学招聘博士后 欢迎广大优秀人才!!! +5 SCSIOyxguo 2026-09-03 8/400 2026-09-06 15:06 by 可爱小花朵
[考博] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +3 j5mmowWXNWxv 2026-09-05 3/150 2026-09-06 13:09 by eObJPa4gWmp6
[教师之家] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +3 j5mmowWXNWxv 2026-09-05 3/150 2026-09-06 13:09 by eObJPa4gWmp6
[考博] 售SCI一区文章,我:8O5.5.1.O5.4,科目全,可伽急 +3 j5mmowWXNWxv 2026-09-05 4/200 2026-09-06 12:49 by eObJPa4gWmp6
[基金申请] 售SCI一区T0P文章,我:8.O.55.1.O.5.4,科目全,可+急 +3 j5mmowWXNWxv 2026-09-05 3/150 2026-09-06 12:49 by eObJPa4gWmp6
[考博] 售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急 +3 j5mmowWXNWxv 2026-09-05 4/200 2026-09-06 12:29 by eObJPa4gWmp6
[找工作] 售一区SCI文章T0P,我:8O.551.O54,科目全,可十急 +3 jPDp0sc2B7zQ 2026-09-05 7/350 2026-09-06 11:40 by eObJPa4gWmp6
[硕博家园] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +3 jPDp0sc2B7zQ 2026-09-05 7/350 2026-09-06 11:20 by eObJPa4gWmp6
[博后之家] 售SCI一区T0P文章,我:8.O.55.1.O.5.4,科目全,可+急 +3 jPDp0sc2B7zQ 2026-09-05 8/400 2026-09-06 11:09 by eObJPa4gWmp6
[教师之家] 售一区SCI文章T0P,我:8O.551.O54,科目全,可十急 +3 jPDp0sc2B7zQ 2026-09-05 8/400 2026-09-06 11:00 by eObJPa4gWmp6
[论文投稿] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +3 jPDp0sc2B7zQ 2026-09-04 8/400 2026-09-06 11:00 by eObJPa4gWmp6
[考研] 售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急 +3 jPDp0sc2B7zQ 2026-09-05 4/200 2026-09-06 07:20 by E1iiBLMU2XnD
[硕博家园] 售SCI文章,我:8O.5.5.1O.54,科目全,可十急 +3 jPDp0sc2B7zQ 2026-09-05 5/250 2026-09-06 02:39 by E1iiBLMU2XnD
[论文投稿] 售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急 +3 jPDp0sc2B7zQ 2026-09-05 5/250 2026-09-06 02:19 by E1iiBLMU2XnD
[基金申请] 面上没中,邀请各位路过的虫友分析一下分数 +12 jackleilei 2026-09-03 13/650 2026-09-05 18:10 by fireguard
[文学芳草园] 两块石头 +6 阿美_Lml888 2026-09-03 8/400 2026-09-05 13:52 by 阿美_Lml888
[文学芳草园] 初秋的晨风 +4 阿美_Lml888 2026-09-04 6/300 2026-09-05 13:51 by 阿美_Lml888
[基金申请] 学科评审组评审是指会评吗? +6 瞬息宇宙 2026-08-31 9/450 2026-09-05 13:11 by haizai99
[硕博家园] 哈尔滨工业大学韩晓军教授课题组招收2027年硕士推免生及博士研究生 +3 灯灯灯灯DDDD 2026-09-03 3/150 2026-09-03 21:22 by 科研皮皮猪
[基金申请] 要骂人了,新模版改版就是要淡化问题凝练这种虚的东西,结果有个评委还在说凝练得不够 +9 瞬息宇宙 2026-08-31 17/850 2026-09-02 14:04 by anjeeshine
信息提示
请填处理意见