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 Center および File ExchangePolymers についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by