Function solving for y

2 次查看(过去 30 天)
Rose Vogt
Rose Vogt 2020-12-12
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