matlab使用fsolve求解方程时返回的数据类型出现错误。
조회 수: 2 (최근 30일)
이전 댓글 표시
建立调用函数:
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.
댓글 수: 0
채택된 답변
果博东方开户【微8785092】
2023년 5월 23일
仅供参考
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!