MATLAB中fsolve解非线性方程问题
clearall;clc;closeall;N1=1;%N2=2;%%P1=750/1120;f=50;%%%%基值定义开始%定SacB=1120;%MVAUacB=55...
clear all;clc;close all;
N1=1;%
N2=2;%%
P1=750/1120;
f=50;
%%%%基值定义开始
%定
SacB=1120;%MVA
UacB=550;%kV
IacB=SacB/UacB/(sqrt(3));
ZacB=UacB*UacB/SacB;%ohm
%定义
SdcB=1120;
UdcB=250;
K=UdcB/UacB;
IdcB=sqrt(3)*IacB/K;
ZdcB=K*K*ZacB;
%%%%基值定义完毕
%%
Kb=2;
Kp=1;
Kunit=1;
Dxi=Kb*0.12*3/pi/K/K*SacB/450;
Dxr=Kb*0.12*3/pi/K/K*SacB/450;
Tr=(1.05*525/105.75);
Ti=(1.0375*525/105.75);
Rdc=20/ZdcB;
gam=17/180*pi;
Ids=3/IdcB;
pi=3.14159;
P2=0;
Q2=0;
P3=0;
Q3=0;
v1=1.08;
v4=1;
R12=6.875E-9*16000*500*500/100/ZacB/N2;
X12=1.0E-7*16000*500*500/100/ZacB/N2+0.181/N1;
R34=0;
X34=0.0732*2*pi*f/ZacB;
R22=4.7241/Kunit/ZacB;X22=-340.2973/Kunit/ZacB;
R33=4.7812/Kunit/ZacB;X33=-308.5175/Kunit/ZacB;
%R22=16.6152/Kunit/ZacB;X22=-638.0362/Kunit/ZacB;
%R33=16.611/Kunit/ZacB;X33=-574.8844/Kunit/ZacB;
l=1;
syms deta1 v2 deta2 v3 deta3;
%五个未知数;需要五个方程
eq1=P1-real(v1*(cos(deta1)+j*sin(deta1))*conj((v1*(cos(deta1)+j*sin(deta1))-v2*(cos(deta2)+j*sin(deta2)))/(R12+j*X12)));
eq2=-P2+real(v2*(cos(deta2)+j*sin(deta2))*conj((v2*(cos(deta2)+j*sin(deta2))-v1*(cos(deta1)+j*sin(deta1)))/(R12+j*X12)))+Kp*(3*sqrt(2)*Kb*v3/pi/Ti/K*cos(gam)+(Rdc-Dxi)*Ids)*Ids;
eq3=-Q2+imag(v2*(cos(deta2)+j*sin(deta2))*conj((v2*(cos(deta2)+j*sin(deta2))-v1*(cos(deta1)+j*sin(deta1)))/(R12+j*X12)))+126*3/SacB+Kp*Ids*(sqrt((3*sqrt(2)*Kb*v2/pi/Tr/K)^2-(3*sqrt(2)*Kb*v3/pi/Ti/K*cos(gam)+(Rdc-Dxi)*Ids)^2));
eq4=-P3+real(v3*(cos(deta3)+j*sin(deta3))*conj((v3*(cos(deta3)+j*sin(deta3))-v4)/(R34+j*X34)))-Kp*(3*sqrt(2)*Kb*v3/pi/Ti/K*cos(gam)-Dxi*Ids)*Ids;
eq5=-Q3+imag(v3*(cos(deta3)+j*sin(deta3))*conj((v3*(cos(deta3)+j*sin(deta3))-v4)/(R34+j*X34)))+126*3/SacB-Kp*Ids*(sqrt((3*sqrt(2)*Kb*v3/pi/Ti/K)^2-(3*sqrt(2)*Kb*v3/pi/Ti/K*cos(gam)-Dxi*Ids)^2));
eq=['F=' char('[') eq1 char(';') eq2 char(';') eq3 char(';') eq4 char(';') eq5 char(']') char(';')];
fid=fopen(['pffun' num2str(l) '.m'],'w');
fwrite(fid,'function F = pffun(x)');
fwrite(fid,char(13));
fwrite(fid,eq);
fwrite(fid, char(13));
fwrite(fid,'return');
fclose(fid);
主函数为
icount=1;
fun=str2func(['pffun' num2str(icount)]);
sol=fsolve(str2func(['pffun' num2str(icount)]),[0.48;1.165; 0.3;1.02;0.118]);
%syms deta1 v2 deta2 v3 deta3;
为什么得到以下结果
Optimizer appears to be converging to a point which is not a root.
Norm of relative change in X is less than max(options.TolX^2,eps) but
sum-of-squares of function values is greater than or equal to sqrt(options.TolFun)
Try again with a new starting guess.
有时又是这样的结果Maximum number of function evaluations reached:
increase options.MaxFunEvals. 展开
N1=1;%
N2=2;%%
P1=750/1120;
f=50;
%%%%基值定义开始
%定
SacB=1120;%MVA
UacB=550;%kV
IacB=SacB/UacB/(sqrt(3));
ZacB=UacB*UacB/SacB;%ohm
%定义
SdcB=1120;
UdcB=250;
K=UdcB/UacB;
IdcB=sqrt(3)*IacB/K;
ZdcB=K*K*ZacB;
%%%%基值定义完毕
%%
Kb=2;
Kp=1;
Kunit=1;
Dxi=Kb*0.12*3/pi/K/K*SacB/450;
Dxr=Kb*0.12*3/pi/K/K*SacB/450;
Tr=(1.05*525/105.75);
Ti=(1.0375*525/105.75);
Rdc=20/ZdcB;
gam=17/180*pi;
Ids=3/IdcB;
pi=3.14159;
P2=0;
Q2=0;
P3=0;
Q3=0;
v1=1.08;
v4=1;
R12=6.875E-9*16000*500*500/100/ZacB/N2;
X12=1.0E-7*16000*500*500/100/ZacB/N2+0.181/N1;
R34=0;
X34=0.0732*2*pi*f/ZacB;
R22=4.7241/Kunit/ZacB;X22=-340.2973/Kunit/ZacB;
R33=4.7812/Kunit/ZacB;X33=-308.5175/Kunit/ZacB;
%R22=16.6152/Kunit/ZacB;X22=-638.0362/Kunit/ZacB;
%R33=16.611/Kunit/ZacB;X33=-574.8844/Kunit/ZacB;
l=1;
syms deta1 v2 deta2 v3 deta3;
%五个未知数;需要五个方程
eq1=P1-real(v1*(cos(deta1)+j*sin(deta1))*conj((v1*(cos(deta1)+j*sin(deta1))-v2*(cos(deta2)+j*sin(deta2)))/(R12+j*X12)));
eq2=-P2+real(v2*(cos(deta2)+j*sin(deta2))*conj((v2*(cos(deta2)+j*sin(deta2))-v1*(cos(deta1)+j*sin(deta1)))/(R12+j*X12)))+Kp*(3*sqrt(2)*Kb*v3/pi/Ti/K*cos(gam)+(Rdc-Dxi)*Ids)*Ids;
eq3=-Q2+imag(v2*(cos(deta2)+j*sin(deta2))*conj((v2*(cos(deta2)+j*sin(deta2))-v1*(cos(deta1)+j*sin(deta1)))/(R12+j*X12)))+126*3/SacB+Kp*Ids*(sqrt((3*sqrt(2)*Kb*v2/pi/Tr/K)^2-(3*sqrt(2)*Kb*v3/pi/Ti/K*cos(gam)+(Rdc-Dxi)*Ids)^2));
eq4=-P3+real(v3*(cos(deta3)+j*sin(deta3))*conj((v3*(cos(deta3)+j*sin(deta3))-v4)/(R34+j*X34)))-Kp*(3*sqrt(2)*Kb*v3/pi/Ti/K*cos(gam)-Dxi*Ids)*Ids;
eq5=-Q3+imag(v3*(cos(deta3)+j*sin(deta3))*conj((v3*(cos(deta3)+j*sin(deta3))-v4)/(R34+j*X34)))+126*3/SacB-Kp*Ids*(sqrt((3*sqrt(2)*Kb*v3/pi/Ti/K)^2-(3*sqrt(2)*Kb*v3/pi/Ti/K*cos(gam)-Dxi*Ids)^2));
eq=['F=' char('[') eq1 char(';') eq2 char(';') eq3 char(';') eq4 char(';') eq5 char(']') char(';')];
fid=fopen(['pffun' num2str(l) '.m'],'w');
fwrite(fid,'function F = pffun(x)');
fwrite(fid,char(13));
fwrite(fid,eq);
fwrite(fid, char(13));
fwrite(fid,'return');
fclose(fid);
主函数为
icount=1;
fun=str2func(['pffun' num2str(icount)]);
sol=fsolve(str2func(['pffun' num2str(icount)]),[0.48;1.165; 0.3;1.02;0.118]);
%syms deta1 v2 deta2 v3 deta3;
为什么得到以下结果
Optimizer appears to be converging to a point which is not a root.
Norm of relative change in X is less than max(options.TolX^2,eps) but
sum-of-squares of function values is greater than or equal to sqrt(options.TolFun)
Try again with a new starting guess.
有时又是这样的结果Maximum number of function evaluations reached:
increase options.MaxFunEvals. 展开
1个回答
展开全部
第一个结果是说,精度options.Tol已经满足要求,但这个精度options.TolFun不满足,让你更改初值试试。
第二个结果是说已经达到最大计算次数,可以通过提高options.MaxFunEvals来增加计算次数。
matlab也是做数值计算的,对计算非线性函数难免受初值选取、精确度满足、步长选择等影响。上面的问题基本也是这样,可以通过设置options来修正,options是个大域名,计算后可以通过在命令窗口输入options来查看各个变量,输入options.变量名 来查看各个变量值,比如options.MaxFunEvals。
x = fsolve(fun,x0,options)你可以多了解下它的用法,网上有很多,第三项是options选项,options各变量有默认值,你可以更改,来控制计算。
如果再不能的话,估计就是函数太过复杂,或太过矫情,不是fsolve所能计算的。
options=optimset('MaxFunEvals',~...)
optimset
Display: [ off | iter | notify | final ]
MaxFunEvals: [ positive scalar ]
MaxIter: [ positive scalar ]
.............
第二个结果是说已经达到最大计算次数,可以通过提高options.MaxFunEvals来增加计算次数。
matlab也是做数值计算的,对计算非线性函数难免受初值选取、精确度满足、步长选择等影响。上面的问题基本也是这样,可以通过设置options来修正,options是个大域名,计算后可以通过在命令窗口输入options来查看各个变量,输入options.变量名 来查看各个变量值,比如options.MaxFunEvals。
x = fsolve(fun,x0,options)你可以多了解下它的用法,网上有很多,第三项是options选项,options各变量有默认值,你可以更改,来控制计算。
如果再不能的话,估计就是函数太过复杂,或太过矫情,不是fsolve所能计算的。
options=optimset('MaxFunEvals',~...)
optimset
Display: [ off | iter | notify | final ]
MaxFunEvals: [ positive scalar ]
MaxIter: [ positive scalar ]
.............
Sievers分析仪
2024-10-13 广告
2024-10-13 广告
是的。传统上,对于符合要求的内毒素检测,最终用户必须从标准内毒素库存瓶中构建至少一式两份三点标准曲线;必须有重复的阴性控制;每个样品和PPC必须一式两份。有了Sievers Eclipse内毒素检测仪,这些步骤可以通过使用预嵌入的内毒素标准...
点击进入详情页
本回答由Sievers分析仪提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询