Im putting in my equations wrong and i need help

3 次查看(过去 30 天)
T1=30
T2=45
T3=60
g= 9.81
y0=3.5
v0= 25
d1= (v0.*cosd(T2)/g).*((v0.*sind(T2))+sqrt((v0.*sind(T2))).^(2)+(2.*g.*y0))
x1= linspace(0,d1,200)
y1= ((x1.*tand(30))-(1/2).*(((x1.^2).*(g))./((25).*cosd(30)))+y0)
d2= (v0.*cosd(T2)/g).*(v0.*sind(T2))+sqrt((v0.*sind(T2))).^(2)+(2.*g.*y0);
x2= linspace(0,d2,200);
y2= (x2.*tand(T2))-(1/2).*(((x2).^2).*g)/(v0.*(cosd(T2)).^(2)+y0);
d3= (v0.*cosd(T3)/g).*(v0.*sind(T3))+sqrt(((v0.*sind(T3))).^(2)+(2.*g.*y0));
x3= linspace(0,d3,200);
y3= (x3.*tand(T3))-(1/2).*(((x3).^(2)).*g)/(v0.*(cosd(T3)).^(2) +y0);
y1 = transpose (y1);
y2 = transpose (y2);
y3 = transpose (y3);
plot(x1,y1)
hold on
plot(x2,x3)
hold on
plot(x3,y3)
hold on
here are the equations i need to imput please feel free to tell me if there are other issues

回答(2 个)

Sindar
Sindar 2020-9-24
编辑:Sindar 2020-9-24
should that be T1? also, replace 25 hardcoding with v0 (and 30 with T1)
d1= (v0.*cosd(T2)/g).*((v0.*sind(T2))+sqrt((v0.*sind(T2))).^(2)+(2.*g.*y0))
x1= linspace(0,d1,200)
y1= ((x1.*tand(30))-(1/2).*(((x1.^2).*(g))./((25).*cosd(30)))+y0)
otherwise, it looks okay. If you're going to be doing this a lot, I'd define a function for each equation, or at least vectorize the code

VBBV
VBBV 2023-4-24
There are several changes needed in your equations, please look at the comments in the code where the changes are necessary
T1=30;
T2=45;
T3=60;
g= 9.81;
y0=3.5;
v0= 25;
% below line, you need to use T1 in place of T2
d1= (v0.*cosd(T1)/g).*(v0.*sind(T1)+sqrt((v0.*sind(T1)).^2+(2.*g.*y0)));
% ^T1 instead of T2 ^ T1 ^ T1
x1= linspace(0,d1,200);
y1= x1.*tand(T1)-(1/2).*((x1.^2.*g)./(v0.*cosd(T1)).^2)+y0;
% ^^ square term is
% missing and parenthesis
% closed incorrectly
d2= (v0.*cosd(T2)/g).*(v0.*sind(T2)+sqrt((v0.*sind(T2)).^2+(2.*g.*y0)));
x2= linspace(0,d2,200);
y2= x2.*tand(T2)-(1/2).*((x2.^2.*g)./(v0.*cosd(T2)).^2)+y0;
% ^^same here
d3= (v0.*cosd(T3)/g).*(v0.*sind(T3)+sqrt((v0.*sind(T3)).^2+(2.*g.*y0)));
x3= linspace(0,d2,200);
y3= x3.*tand(T3)-(1/2).*((x3.^2.*g)./(v0.*cosd(T3)).^2)+y0;
% ^^ same here
y1 = transpose (y1);
y2 = transpose (y2);
y3 = transpose (y3);
hold on
plot(x1,y1)
plot(x2,x3)
plot(x3,y3)
legend('\Theta = 30^{0}','\Theta = 45^{0}','\Theta = 60^{0}'); grid

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by