matlab使用fs​olve求解方程时返​回的数据类型出现错误​。

建立调用函数:
function F=myfun(a)
syms a
r1=34.5;a2=0.4472;r=0.38*3;k2=tan(43*pi/138);
x1r11=1.3459+r*(cos(a2)-cos(a));
y1r11=-3+r*(sin(a2)-sin(a));
v2=(x1r11-y1r11*cot(a))/r1;
x1r1=x1r11*cos(v2)+y1r11*sin(v2)+r1*(sin(v2)-v2*cos(v2));%主动轮齿根过渡曲线
y1r1=-x1r11*sin(v2)+y1r11*cos(v2)+r1*(cos(v2)+v2*sin(v2))-34.5;%齿轮啮合原理式1-120
F=diff(y1r1)/diff(x1r1)+1/k2;
end
matlab主程序:
F=@myfun;
a1=fsolve(F,0)
错误使用fsolve
FSOLVE requires all values returned by functions to be of data type double.

 Réponse acceptée

0 votes

仅供参考
opts = optimoptions(@fsolve,'Algorithm', 'levenberg-marquardt');
F=@myfun;
a1=fsolve(F,0,opts)
function F=myfun(a)
r1=34.5;a2=0.4472;r=0.38*3;k2=tan(43*pi/138);
x1r11=1.3459+r*(cos(a2)-cos(a));
y1r11=-3+r*(sin(a2)-sin(a));
v2=(x1r11-y1r11*cot(a))/r1;
x1r1=x1r11*cos(v2)+y1r11*sin(v2)+r1*(sin(v2)-v2*cos(v2));%主动轮齿根过渡曲线
y1r1=-x1r11*sin(v2)+y1r11*cos(v2)+r1*(cos(v2)+v2*sin(v2))-34.5;%齿轮啮合原理式1-120
F=diff(y1r1)/diff(x1r1)+1/k2;
end

Plus de réponses (0)

Catégories

En savoir plus sur Symbolic Math Toolbox dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!