Hello MATLAB community,
I am working on this projectile problem and I am utilizing the for loop command for several times. But I really feel like there must be a cleaner way to do it by using only one for loop command, but I am not sure though. And also, is there any way I can find the specific index where the hPluto is 0 and so forth with the other h's?
Vi = 25;
t1 = [0:0.1:86.3];
t2 = [0:0.1:13.5];
t3 = [0:0.1:13.5];
t4 = [0:0.1:6];
g = [0.58 3.7 3.71 8.87]
for i = 1:length(t1)
hPluto = Vi .* t1 - 0.5 .* g(1) .* t1 .^ 2;
end
for i = 1:length(t2)
hMercury = Vi .* t2 - 0.5 .*g(2) .* t2 .^2;
end
for i = 1:length(t3)
hMars = Vi .* t3 - 0.5 .*g(3) .* t3 .^2;
end
for i = 1:length(t4)
hVenus = Vi .* t4 - 0.5 .*g(4) .* t4 .^2;
end
plot(t1, hPluto, t2, hMercury, t3, hMars, t4, hVenus)