Question

For this homework you will be creating functions in SciLab. You will turn in electronically, each of the functions requested

0 0
Add a comment Improve this question Transcribed image text
Answer #1


Scilab code for projectile motion clear all close all %1st projectile v90;angle-20;g=9.81; [X,Y]=Projectile (v,angle , g); suFunction for projectile motion function X, Y]=Projectile (Velocity,angle,gravity) vo-velocity th-(pi/180)*angle; t 0; k-1; yy

%%Scilab code for projectile motion
clear all
close all

%1st projectile
v=90;angle=20;g=9.81;
[X,Y]=Projectile(v,angle,g);
figure(1)
subplot(4,1,1)
plot(X,Y)
legend('For angle 20')
xlabel('X in m.')
ylabel('Y in m.')
title('Projectile motion')
ylim([0 250])
xlim([0 900])

%2nd projectile
v=90;angle=30;g=9.81;
[X,Y]=Projectile(v,angle,g);
subplot(4,1,2)
plot(X,Y)
legend('For angle 30')
xlabel('X in m.')
ylabel('Y in m.')
title('Projectile motion')
ylim([0 250])
xlim([0 900])

%3rd projectile
v=90;angle=40;g=9.81;
[X,Y]=Projectile(v,angle,g);
subplot(4,1,3)
plot(X,Y)
legend('For angle 40')
xlabel('X in m.')
ylabel('Y in m.')
title('Projectile motion')
ylim([0 250])
xlim([0 900])

%4th projectile
v=90;angle=50;g=9.81;
[X,Y]=Projectile(v,angle,g);
subplot(4,1,4)
plot(X,Y)
legend('For angle 50')
xlabel('X in m.')
ylabel('Y in m.')
title('Projectile motion')
ylim([0 250])
xlim([0 900])

%%Function for projectile motion
function [X,Y]=Projectile(Velocity,angle,gravity)

    v0=Velocity;
    th=(pi/180)*angle;
    t=0; k=1; yy=1;
    X(1)=0;Y(1)=0;
    while yy>-0.01
        t=t+0.1;
        k=k+1;
        X(k)=v0*t*cos(th);
        Y(k)=v0*t*sin(th)-0.5*gravity*t^2;
        yy=Y(k);
    end
end

%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%

Add a comment
Know the answer?
Add Answer to:
For this homework you will be creating functions in SciLab. You will turn in electronically, each of the functions requ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT