请求帮助:大家看看这个程序为什么运行不了
不太会用matlab,问一个问题,大家帮忙看一下,很着急的,谢谢这样的方程(j=1,2,3........11),我编了一个程序,但是解不出结果
方程组的程序
function F=myfunlh(x)
fe=0.52;
fi=0.515;
Fa=1000;
Fr=2000;
Ki=381447.0905;
Ke=329428.2257;
a=15*pi/180;
Db=11;
Dm=82;
w=1046;
p=7800;
r=11/82;
My=200;
Ri=41;
for m=0:1:10
y(m+1)=m*18*pi/180; %y为滚球在轴承中所处的角位置
end
%输入方程组
for j=0:1:10
F(j*1+1,1)=Ki*(x(23+j)^1.5)*sin(x(j+1))-Ke*(x(34+j)^1.5)*sin(x(12+j))-(pi*p*((Db/1000)^4)*(w^2)/(30))*(sin(x(12+j))*cos(x(12+j))/r)*(((1-r*cos(x(j+1)))/(1+cos(x(j+1)-x(12+j))))^2);
F(j*1+2,1)=Ki*(x(23+j)^1.5)*cos(x(j+1))-Ke*(x(34+j)^1.5)*cos(x(12+j))+(p*pi*((Db/1000)^4)*(w^2)/(30*r))*((sin(x(12+j)))^2)*(((1-r*cos(x(j+1)))/(1+cos(x(j+1)-x(12+j))))^2)+(pi*p*((Db/1000)^3)*(Dm/1000)*(w^2)/12)*(((1-r*cos(x(j+1)))/(1+cos(x(j+1)-x(12+j))))^2);
F(j*1+3,1)=((fe-0.5)*Db+x(34+j))*sin(x(12+j))+((fi-0.5)*Db+x(23+j))*sin(x(j+1))-(fe+fi-1)*Db*sin(a)-x(45);
F(j*1+4,1)=((fe-0.5)*Db+x(34+j))*cos(x(12+j))+((fi-0.5)*Db+x(23+j))*cos(x(j+1))-(fe+fi-1)*Db*cos(a)-x(46)*cos(y(j+1));
end
F(45,1)=Fa-Ki*(x(23)^1.5)*sin(x(1))-2*Ki*(x(24)^1.5)*sin(x(2))-2*Ki*(x(25)^1.5)*sin(x(3))-2*Ki*(x(26)^1.5)*sin(x(4))-2*Ki*(x(27)^1.5)*sin(x(5))-2*Ki*(x(28)^1.5)*sin(x(6))-2*Ki*(x(29)^1.5)*sin(x(7)*pi/180)-2*Ki*(x(30)^1.5)*sin(x(8))-2*Ki*(x(31)^1.5)*sin(x(9))-2*Ki*(x(32)^1.5)*sin(x(10))-Ki*(x(33)^1.5)*sin(x(11));
F(46,1)=Fr-Ki*(x(23)^1.5)*cos(x(1))-2*Ki*(x(24)^1.5)*cos(x(2))-2*Ki*((x(25)^1.5)*cos(x(3))-2*Ki*(x(26)^1.5)*cos(x(4))-2*Ki*(x(27)^1.5)*cos(x(5))-2*Ki*(x(28)^1.5)*cos(x(6))-2*Ki*(x(29)^1.5)*cos(x(7)*pi/180)-2*Ki*(x(30)^1.5)*cos(x(8))-2*Ki*(x(31)^1.5)*cos(x(9))-2*Ki*(x(32)^1.5)*cos(x(10))-Ki*(x(33)^1.5)*cos(x(11));
F(47,1)=My-2*(Ri*(Ki*(Si(1)^1.5)*sin(ai(1)*pi/180)*cos(y(1))-Ki*(Si(2)^1.5)*sin(ai(2)*pi/180)*cos(y(2))-Ki*(Si(3)^1.5)*sin(ai(3)*pi/180)*cos(y(3))-Ki*(Si(4)^1.5)*sin(ai(4)*pi/180)*cos(y(4))-Ki*(Si(5)^1.5)*sin(ai(5)*pi/180)*cos(y(5))-Ki*(Si(6)^1.5)*sin(ai(6)*pi/180)*cos(y(6))-Ki*(Si(7)^1.5)*sin(ai(7)*pi/180)*cos(y(7))-Ki*(Si(8)^1.5)*sin(ai(8)*pi/180)*cos(y(8))-Ki*(Si(9)^1.5)*sin(ai(9)*pi/180)*cos(y(9))-Ki*(Si(10)^1.5)*sin(ai(10)*pi/180)*cos(y(10))-Ki*(Si(11)^1.5)*sin(ai(11)*pi/180)*cos(y(11))));
然后在命令框中输入
x0=;
>> options=optimset('Display','iter');
>> = fsolve(@myfunlh,x0,options);
为什么算不出结果啊
??? Error: File: d:\MATLAB7\work\myfunlh.m Line: 25 Column: 314
Incomplete or misformed expression or statement.
Error in ==> fsolve at 180
fuser = feval(funfcn{3},x,varargin{:});
回复:(wyllzy)请求帮助:大家看看这个程序为什么运...
仔细检查一下你的程序,主要是下面部分for j=0:1:10
F(j*1+1,1)=Ki*(x(23+j)^1.5)*sin(x(j+1))-Ke*(x(34+j)^1.5)*sin(x(12+j))-(pi*p*((Db/1000)^4)*(w^2)/(30))*(sin(x(12+j))*cos(x(12+j))/r)*(((1-r*cos(x(j+1)))/(1+cos(x(j+1)-x(12+j))))^2);
F(j*1+2,1)=Ki*(x(23+j)^1.5)*cos(x(j+1))-Ke*(x(34+j)^1.5)*cos(x(12+j))+(p*pi*((Db/1000)^4)*(w^2)/(30*r))*((sin(x(12+j)))^2)*(((1-r*cos(x(j+1)))/(1+cos(x(j+1)-x(12+j))))^2)+(pi*p*((Db/1000)^3)*(Dm/1000)*(w^2)/12)*(((1-r*cos(x(j+1)))/(1+cos(x(j+1)-x(12+j))))^2);
F(j*1+3,1)=((fe-0.5)*Db+x(34+j))*sin(x(12+j))+((fi-0.5)*Db+x(23+j))*sin(x(j+1))-(fe+fi-1)*Db*sin(a)-x(45);
F(j*1+4,1)=((fe-0.5)*Db+x(34+j))*cos(x(12+j))+((fi-0.5)*Db+x(23+j))*cos(x(j+1))-(fe+fi-1)*Db*cos(a)-x(46)*cos(y(j+1));
end
F(45,1)=Fa-Ki*(x(23)^1.5)*sin(x(1))-2*Ki*(x(24)^1.5)*sin(x(2))-2*Ki*(x(25)^1.5)*sin(x(3))-2*Ki*(x(26)^1.5)*sin(x(4))-2*Ki*(x(27)^1.5)*sin(x(5))-2*Ki*(x(28)^1.5)*sin(x(6))-2*Ki*(x(29)^1.5)*sin(x(7)*pi/180)-2*Ki*(x(30)^1.5)*sin(x(8))-2*Ki*(x(31)^1.5)*sin(x(9))-2*Ki*(x(32)^1.5)*sin(x(10))-Ki*(x(33)^1.5)*sin(x(11));
F(46,1)=Fr-Ki*(x(23)^1.5)*cos(x(1))-2*Ki*(x(24)^1.5)*cos(x(2))-2*Ki*(x(25)^1.5)*cos(x(3))-2*Ki*(x(26)^1.5)*cos(x(4))-2*Ki*(x(27)^1.5)*cos(x(5))-2*Ki*(x(28)^1.5)*cos(x(6))-2*Ki*(x(29)^1.5)*cos(x(7)*pi/180)-2*Ki*(x(30)^1.5)*cos(x(8))-2*Ki*(x(31)^1.5)*cos(x(9))-2*Ki*(x(32)^1.5)*cos(x(10))-Ki*(x(33)^1.5)*cos(x(11));
F(47,1)=My-2*(Ri*(Ki*(Si(1)^1.5)*sin(ai(1)*pi/180)*cos(y(1))-Ki*(Si(2)^1.5)*sin(ai(2)*pi/180)*cos(y(2))-Ki*(Si(3)^1.5)*sin(ai(3)*pi/180)*cos(y(3))-Ki*(Si(4)^1.5)*sin(ai(4)*pi/180)*cos(y(4))-Ki*(Si(5)^1.5)*sin(ai(5)*pi/180)*cos(y(5))-Ki*(Si(6)^1.5)*sin(ai(6)*pi/180)*cos(y(6))-Ki*(Si(7)^1.5)*sin(ai(7)*pi/180)*cos(y(7))-Ki*(Si(8)^1.5)*sin(ai(8)*pi/180)*cos(y(8))-Ki*(Si(9)^1.5)*sin(ai(9)*pi/180)*cos(y(9))-Ki*(Si(10)^1.5)*sin(ai(10)*pi/180)*cos(y(10))-Ki*(Si(11)^1.5)*sin(ai(11)*pi/180)*cos(y(11))));
其中存在括号不对应和指标越界问题
回复:(wyllzy)请求帮助:大家看看这个程序为什么运...
Norm of First-order Trust-regionIteration Func-count f(x) step optimality radius
0 47 543914 1.1e+007 1
1 94 500195 0.00136783 6.15e+006 1
2 141 490809 0.00112374 6.74e+006 1
3 188 482709 0.000632262 6.25e+006 1
4 235 475315 0.000857996 6.43e+006 1
5 282 468482 0.000613475 5.75e+006 1
6 329 462186 0.000724299 5.88e+006 1
7 376 456115 0.000610749 5.12e+006 1
8 423 450380 0.000648639 5.32e+006 1
。。。。。。。。。。。。
93 4418 100657 7.13849e-005 4.78e+005 1
94 4465 100574 0.000128536 4.78e+005 1
95 4512 100491 7.17444e-005 4.78e+005 1
96 4559 100406 0.000132057 4.78e+005 1
97 4606 100321 7.21529e-005 4.78e+005 1
Maximum number of function evaluations reached:
increase options.MaxFunEvals.
谢谢楼上
能运行了,但是为什么结果不对,根本就没什么变化
应该怎样设置一些参数
增加MaxFunEvals有用么(怎么改这个参数啊)
回复:(wyllzy)回复:(wyllzy)请求帮助:大家看看...
MaxFunEvals函数评价的最大允许次数多调整几次,如果还是不行那很可能是你给的初值或者本身的问题了
页:
[1]