where I am making a mistake while using fsolve to evaluate two unknown with two equation

조회 수: 8 (최근 30일)
N2 = 6;
N1 = 5;
R2 = (80.02*N1/(N1+N2));
ha = (80.02*N1/(N1+N2))-35.2088;
hd = (80.02*N2/(N1+N2))-23.4725;
u = degtorad(6.291);
R1 = (80.02*N2/(N1+N2));
rho1 = 1.675;
f1 = @(N1, N2, R1, R2, ha, hd, u, rho1, theta2, t)[((R2*theta2-((ha-rho1)./tan(u)-t./sin(u)))./cos(-atan(((R2./(cos(((ha-rho1)./tan(u)-t./sin(u))./R2)+sin(((ha-rho1)./tan(u)-t./sin(u))./R2)*tan(u)))*cos(theta2)-R2)./((R2./(cos(((ha-rho1)./tan(u)-t./sin(u))./R2)+sin(((ha-rho1)./tan(u)-t./sin(u))./R2)*tan(u)))*sin(theta2))))-R1*(1-cos((N2./N1)*(theta2-((ha-rho1)./tan(u)-t./sin(u))./R2)))./sin((-atan(((R2./(cos(((ha-rho1)./tan(u)-t./sin(u))./R2)+sin(((ha-rho1)./tan(u)-t./sin(u))./R2)*tan(u)))*cos(theta2)-R2)./((R2./(cos(((ha-rho1)./tan(u)-t./sin(u))./R2)+sin(((ha-rho1)./tan(u)-t./sin(u))./R2)*tan(u)))*sin(theta2))))+((N2./N1)*(theta2-((ha-rho1)./tan(u)-t./sin(u))./R2)))-hd),
(-R2*theta2+(R2./(cos(((ha-rho1)./tan(u)-t./sin(u))./R2)+sin(((ha-rho1)./tan(u)-t./sin(u))./R2)*tan(u)))*sin(theta2)-((-((ha-rho1)./tan(u)-t./sin(u))+(R2./(cos(((ha-rho1)./tan(u)-t./sin(u))./R2)+sin(((ha-rho1)./tan(u)-t./sin(u))./R2)*tan(u)))*sin((((ha-rho1)./tan(u)-t./sin(u))./R2)))./cos(u)+rho1+t*tan(u))*cos(-atan(((R2./(cos(((ha-rho1)./tan(u)-t./sin(u))./R2)+sin(((ha-rho1)./tan(u)-t./sin(u))./R2)*tan(u)))*cos(theta2)-R2)./((R2./(cos(((ha-rho1)./tan(u)-t./sin(u))./R2)+sin(((ha-rho1)./tan(u)-t./sin(u))./R2)*tan(u)))*sin(theta2))))+((ha-rho1)./tan(u)-t./sin(u)))];
x=fsolve(@(theta2,t)f1(N1, N2, R1, R2, ha, hd, u, rho1, theta2, t),[degtorad(20),1]);
Not enough input arguments.

Error in solution>@(theta2,t)f1(N1,N2,R1,R2,ha,hd,u,rho1,theta2,t) (line 15)
x=fsolve(@(theta2,t)f1(N1, N2, R1, R2, ha, hd, u, rho1, theta2, t),[degtorad(20),1]);

Error in fsolve (line 267)
fuser = feval(funfcn{3},x,varargin{:});

Caused by:
Failure in initial objective function evaluation. FSOLVE cannot continue.

채택된 답변

Star Strider
Star Strider 2023년 7월 6일
Only one minor problem. The fsolve function needs and returns a vector of paramters.
Changing that call to:
x=fsolve(@(b)f1(N1, N2, R1, R2, ha, hd, u, rho1, b(1), b(2)),[degtorad(20),1])
so that ‘theta2’ is ‘b(1)’ and ‘t’ is ‘b(2)’ gives it what it wants, and it now works —
N2 = 6;
N1 = 5;
R2 = (80.02*N1/(N1+N2));
ha = (80.02*N1/(N1+N2))-35.2088;
hd = (80.02*N2/(N1+N2))-23.4725;
u = degtorad(6.291);
R1 = (80.02*N2/(N1+N2));
rho1 = 1.675;
f1 = @(N1, N2, R1, R2, ha, hd, u, rho1, theta2, t)[((R2*theta2-((ha-rho1)./tan(u)-t./sin(u)))./cos(-atan(((R2./(cos(((ha-rho1)./tan(u)-t./sin(u))./R2)+sin(((ha-rho1)./tan(u)-t./sin(u))./R2)*tan(u)))*cos(theta2)-R2)./((R2./(cos(((ha-rho1)./tan(u)-t./sin(u))./R2)+sin(((ha-rho1)./tan(u)-t./sin(u))./R2)*tan(u)))*sin(theta2))))-R1*(1-cos((N2./N1)*(theta2-((ha-rho1)./tan(u)-t./sin(u))./R2)))./sin((-atan(((R2./(cos(((ha-rho1)./tan(u)-t./sin(u))./R2)+sin(((ha-rho1)./tan(u)-t./sin(u))./R2)*tan(u)))*cos(theta2)-R2)./((R2./(cos(((ha-rho1)./tan(u)-t./sin(u))./R2)+sin(((ha-rho1)./tan(u)-t./sin(u))./R2)*tan(u)))*sin(theta2))))+((N2./N1)*(theta2-((ha-rho1)./tan(u)-t./sin(u))./R2)))-hd),
(-R2*theta2+(R2./(cos(((ha-rho1)./tan(u)-t./sin(u))./R2)+sin(((ha-rho1)./tan(u)-t./sin(u))./R2)*tan(u)))*sin(theta2)-((-((ha-rho1)./tan(u)-t./sin(u))+(R2./(cos(((ha-rho1)./tan(u)-t./sin(u))./R2)+sin(((ha-rho1)./tan(u)-t./sin(u))./R2)*tan(u)))*sin((((ha-rho1)./tan(u)-t./sin(u))./R2)))./cos(u)+rho1+t*tan(u))*cos(-atan(((R2./(cos(((ha-rho1)./tan(u)-t./sin(u))./R2)+sin(((ha-rho1)./tan(u)-t./sin(u))./R2)*tan(u)))*cos(theta2)-R2)./((R2./(cos(((ha-rho1)./tan(u)-t./sin(u))./R2)+sin(((ha-rho1)./tan(u)-t./sin(u))./R2)*tan(u)))*sin(theta2))))+((ha-rho1)./tan(u)-t./sin(u)))];
x=fsolve(@(b)f1(N1, N2, R1, R2, ha, hd, u, rho1, b(1), b(2)),[degtorad(20),1])
Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient.
x = 1×2
1.8001 -3.3181
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by