Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am having problems with the projectile :/ Help!!!! Using MATLAB and for loops,

ID: 3551348 • Letter: I

Question

I am having problems with the projectile :/ Help!!!!

Using MATLAB and for loops, provide an animation that follows the below steps: Start with a yellow square with each side being 5 units long The bottom left of the square should be at the origin Imagine someone kicked the box such that the box starts following a projectile motion trajectory Use the previous labs to figure out what equations you need to use Initial velocity (v0) = 50 units/second. Initial angle = 35 degrees While the box is in-flight (i.e. while it is being translated along the projectile trajectory), it should also rotate around its center. When the box hits the ground, it stops Make sure you calculate the total flight time to ensure that the box doesn't go "under the ground"

Explanation / Answer

% run this code
theta=35*pi/180; % initial angle in radian
V0=50;% initial velocity
g=10;%gravity
T=2*(V0*sin(theta)/g);% calculate time of flight
t=0:T/100:T;%create time till flight time
rot=0:360/100:360;% rottion angle
for i=1:length(t)
x(i)=V0*cos(theta)*t(i);%x for projectile
y(i)=V0*sin(theta)*t(i)-0.5*g*t(i)^2;%y for projectile
ph=patch([x(i) x(i)+5 x(i)+5 x(i) ],[y(i) y(i) y(i)+5 y(i)+5],'y');
center=[x(i)+2.5 y(i)+2.5 0];
rotate(ph,[0 0 1],rot(i),center);
daspect([1,1,1]);
xlim([0,250]);
ylim([0,80]);
pause(0.1);%pause for 0.1 sec
clf('reset')
end


you can also download the code i have shared

https://www.dropbox.com/s/k7f1lzar2ik31t2/square.m