Function solving for y

조회 수: 1 (최근 30일)
Rose Vogt
Rose Vogt 2020년 12월 12일
댓글: Rena Berman 2021년 5월 6일
k=ones(4,1);
y=fsolve(cdepth,k);
function N=cdepth(Rh,theta1,y,Ax)
D=1.2; %diameter of tube in m made of smooth plastic
z=4; %elevation change of 4 m per section
L=[6 8 10 5]; %length if each section of the spiral slide
n=.01; %assumed
slope=atan(L./(pi.*D))./100; %slopes of each section of the pipes
Q3=9.921896118095368;
theta1(1)=2.*acos(1-(2.*y(1)./D));
theta1(2)=2.*acos(1-(2.*y(2)./D));
theta1(3)=2.*acos(1-(2.*y(3)./D));
theta1(4)=2.*acos(1-(2.*y(4)./D));
Ax(1)=(1/8)*(theta1(1)-sin(theta1(1))).*D.^2;
Ax(2)=(1/8)*(theta1(2)-sin(theta1(2))).*D.^2;
Ax(3)=(1/8)*(theta1(3)-sin(theta1(3))).*D.^2;
Ax(4)=(1/8)*(theta1(4)-sin(theta1(4))).*D.^2;
Rh(1)=.25.*(1-sin(theta1(1))./theta1(1)).*D;
Rh(2)=.25.*(1-sin(theta1(2))./theta1(2)).*D;
Rh(3)=.25.*(1-sin(theta1(3))./theta1(3)).*D;
Rh(4)=.25.*(1-sin(theta1(4))./theta1(4)).*D;
N(1)=((1./n).*Ax(1).*(Rh(1)).^(2/3).*slope(1).^.5)-Q3;
N(2)=((1./n).*Ax(2).*(Rh(2)).^(2/3).*slope(2).^.5)-Q3;
N(3)=((1./n).*Ax(3).*(Rh(3)).^(2/3).*slope(3).^.5)-Q3;
N(4)=((1./n).*Ax(4).*(Rh(4)).^(2/3).*slope(4).^.5)-Q3;
end
when I try to run my function I get this error code and I'm not sure why. Can anyone help?
Not enough input arguments.
Error in Final_Vogt_RV>cdepth (line 511)
theta1(1)=2.*acos(1-(2.*y(1)./D));
Error in Final_Vogt_RV (line 501)
y=fsolve(cdepth,k);
  댓글 수: 3
Stephen23
Stephen23 2020년 12월 15일
편집: Stephen23 2020년 12월 15일
k=ones(4,1);
y=fsolve(cdepth,k);
function N=cdepth(Rh,theta1,y,Ax)
D=1.2; %diameter of tube in m made of smooth plastic
z=4; %elevation change of 4 m per section
L=[6 8 10 5]; %length if each section of the spiral slide
n=.01; %assumed
slope=atan(L./(pi.*D))./100; %slopes of each section of the pipes
Q3=9.921896118095368;
theta1(1)=2.*acos(1-(2.*y(1)./D));
theta1(2)=2.*acos(1-(2.*y(2)./D));
theta1(3)=2.*acos(1-(2.*y(3)./D));
theta1(4)=2.*acos(1-(2.*y(4)./D));
Ax(1)=(1/8)*(theta1(1)-sin(theta1(1))).*D.^2;
Ax(2)=(1/8)*(theta1(2)-sin(theta1(2))).*D.^2;
Ax(3)=(1/8)*(theta1(3)-sin(theta1(3))).*D.^2;
Ax(4)=(1/8)*(theta1(4)-sin(theta1(4))).*D.^2;
Rh(1)=.25.*(1-sin(theta1(1))./theta1(1)).*D;
Rh(2)=.25.*(1-sin(theta1(2))./theta1(2)).*D;
Rh(3)=.25.*(1-sin(theta1(3))./theta1(3)).*D;
Rh(4)=.25.*(1-sin(theta1(4))./theta1(4)).*D;
N(1)=((1./n).*Ax(1).*(Rh(1)).^(2/3).*slope(1).^.5)-Q3;
N(2)=((1./n).*Ax(2).*(Rh(2)).^(2/3).*slope(2).^.5)-Q3;
N(3)=((1./n).*Ax(3).*(Rh(3)).^(2/3).*slope(3).^.5)-Q3;
N(4)=((1./n).*Ax(4).*(Rh(4)).^(2/3).*slope(4).^.5)-Q3;
end
when I try to run my function I get this error code and I'm not sure why. Can anyone help?
Not enough input arguments.
Error in Final_Vogt_RV>cdepth (line 511)
theta1(1)=2.*acos(1-(2.*y(1)./D));
Error in Final_Vogt_RV (line 501)
y=fsolve(cdepth,k);
Rena Berman
Rena Berman 2021년 5월 6일
(Answers Dev) Restored edit

댓글을 달려면 로그인하십시오.

답변 (1개)

Star Strider
Star Strider 2020년 12월 12일
After making sure that all the arguments are present in your workspace, try this:
y=fsolve(@(y)cdepth(Rh,theta1,y,Ax),k);
That’s the correct syntax. If your function is correct, you should get the correct result.
See the documentation section on Anonymous Functions for details.

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by