MATLAB Answers

Adding vectors on matlab

29 views (last 30 days)
Rose Vogt
Rose Vogt on 12 Dec 2020
Edited: Stephen Cobeldick on 15 Dec 2020
This question was flagged by Rik
how do i add two vectors on matlab ?

  2 Comments

Rik
Rik on 15 Dec 2020
Why did you edit away your question? That is extremely rude. Now the answer doesn't make sense.
Stephen Cobeldick
Stephen Cobeldick on 15 Dec 2020
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);

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 12 Dec 2020
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.

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!