matlab程序:%cf对应的af不唯一,取af大于零的时候 ar=0:0.5:10; syms x assume(x>0) %根据魔术公式求导得到ar-cr的关系,求的cr,cf a0=1.5999;a1=-0.0048;a2=0.9328;a3=4.0847;a4=44.8338; a6=-0.0076;a7=-0.1807;a8=-0.0026;a9=0.0367; a11=0.0004;a12=-0.0115;a17=0.0009; F_zr=m*9.8*lf/(lf+lr)/1000; C=a0*(5-a)/4; D2=(a1*(F_zr^2)+a2*F_zr)*a; B2=(a3*sin(2*atan(F_zr/a4))/(C*D2))*(2-a); Sh2=a8*F_zr+a9; E2=(a6*F_zr+a7); cr=(1000*C*D2*cos(C*atan(E2*(atan(B2*ar) - B2*ar) + B2*ar)).*(B2 - E2*(B2 - B2./(B2^2*ar.^2 + 1))))./((E2*(atan(B2*ar) - B2*ar) + B2*ar).^2 + 1); cf=(m*V^2*lr*cr)./(cr*(lf+lr)*(lf+lr)-m*V^2*lf); % 已知参数 F_zf=m*9.8*(lr)/(lr+lf)/1000; D1=(a1*(F_zf^2)+a2*F_zf)*a; B1=(a3*sin(2*atan(F_zf/a4))/(C*D1))*(2-a); E1=a6*F_zf+a7; % 定义af-cf函数 f=@(x)(1000*C*D1*cos(C*atan(E1*(atan(B1*x) - B1*x) + B1*x)).*(B1 - E1*(B1 - B1./(B1^2*x.^2 + 1))))./((E1*(atan(B1*x) - B1*x) + B1*x).^2 + 1) - cf; % 反求af x0=[0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0]+1; af=fsolve(f,x0); %转化为弧度制 af1=af*pi/180;ar1=ar*pi/180; %求得侧偏角和横摆角速度 r=(V*(cetia-af1+ar1))/(lf+lr); betia=(lf*(cetia-af1)-lf*ar1)/(lf+lr); figure(5); plot(betia,r); axis([-40,40,-40,40]); title('betia-r'); xlabel('betia');ylabel('r'); hold on;报错警告: Trust-region-dogleg algorithm of FSOLVE cannot handle non-square systems; using Levenberg-Marquardt algorithm instead. > 位置:fsolve (第 342 行) 位置: untitled2 (第 36 行) No solution found. fsolve stopped because the last step was ineffective. However, the vector of function values is not near zero, as measured by the value of the function tolerance. <stopping criteria details> >> 请修改
时间: 2023-12-16 18:03:12 浏览: 30
根据错误提示,可以看出问题出现在 fsolve 函数中,具体原因是“Trust-region-dogleg algorithm”算法不能处理非方阵系统。建议尝试使用其他算法,比如 Levenberg-Marquardt 算法。可以在 fsolve 函数中添加选项来指定算法类型,例如:
```
options = optimoptions('fsolve','Algorithm','levenberg-marquardt');
af=fsolve(f,x0,options);
```
另外,可以尝试调整函数 f 的初始值 x0,或者增加迭代次数。如果仍然无法解决问题,建议检查一下输入参数是否正确,或者是否存在其他错误。
相关问题
命令窗口输入:syms x:intx,0,1指令,运行的结果是
输入命令 `syms x:intx,0,1` 后,并不会在命令窗口中显示任何结果。这是因为这个命令并不是要求MATLAB计算某个表达式的值,而是定义了一个符号变量 x,并且将它限制在整数区间 [0, 1] 内。
如果要查看符号变量 x 的定义,可以在命令窗口中输入 `x`,MATLAB会返回:
```
x
ans = intx
```
表示变量 x 被定义为0到1之间的整数。
命令窗口输入:syms x:int(x,0,1)指令,运行的 果为
命令 `syms x:int(x,0,1)` 中的括号不正确,应该是 `syms x int(x,0,1)`。这个命令的含义是定义符号变量 x,并将其限制在整数区间 [0, 1] 内。
运行这个命令后,在命令窗口中不会有任何输出,但是变量 x 已经被成功定义。如果要查看变量 x 的定义,可以在命令窗口中输入 `x`,MATLAB会返回:
```
x
ans = int(x,[0, 1])
```
表示变量 x 被定义为0到1之间的整数。