필터 지우기
필터 지우기

Im putting in my equations wrong and i need help

조회 수: 2 (최근 30일)
Yisroel Rosenberg
Yisroel Rosenberg 2020년 9월 23일
답변: VBBV 2023년 4월 24일
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에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by