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

조회 수: 2 (최근 30일)
果博东方开户注册【微8785092】
建立调用函数:
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.

채택된 답변

果博东方开户【微8785092】
仅供参考
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!