Question

This problem will introduce you the MATLAB (if you have not used it before). In this...

This problem will introduce you the MATLAB (if you have not used it before). In this course we will use MATLAB in a limited fashion to give you a glimpse on how it is used to solve engineering problems. In your junior year, you will spend an entire semester in AEM 3101 becoming very proficient in using MATLAB for engineering modeling and simulation purposes. In this problem you will use MATLAB to accomplish the following tasks:

(a) Write a function rho2h.m which, given density (ρ) in slugs per cubic feet returns altitude (h) in feet above sea level (assuming a standard atmosphere).

(b) Make a plot of time versus density data for a rocket in flight. The data the you will plot is given in the m-script skeleton listed below. Time is in the vector t and density is in the vector rho. The point of this task is make sure you know how to generate professional looking plots using MATLAB.

(c) Use the function you developed in part(a) to generate a second plot of time versus altitude for the same rocket. To get you started, a skeleton of the m-script that will do this has been been provided below. Type it up in the MATLAB editor and save it as an m-script named aem2301_ps_pr_2.m. Then write a function rho2h.m and save it in the same directory you saved aem2301_ps_pr_2.m. Then run aem2301_ps_pr_2.m from the MATLAB command line. The result should be the two plots you are asked to make. The plots generated are going to very plain. You are expected to make them look more professional along the lines we discuss in class. Turn in the two plots and the listing of rho2h.m.

%======================================================================%

% m-script name: aem2301_ps_1_pr_2.m

% Programmer: Your name goes here

% Date created: Date you created this m-script

% Date last modified: Data of the last change to this m-script

%

% Description: This m-script plots time vs. density and time

% time vs. altitude for a rocket in flight %=======================================================================%

% Clear memory and work space

clear all;

close all;

clc;

% Time and density history for the launch and ascent of a rocket

t = [0 10 20 30 40 50 60 70 80 90 100];

% Time in seconds since launch rho = (1e-3)*[2.377 2.208 2.010 2.0624 2.1149... 2.1673 2.2197 2.2721 2.3246 2.3770 2.377];

% Density in slugs/ft^3

% Loop through t and density to calculate altitude

number_of_data_points = length(t);

for k=1:number_of_data_points h(k) = rho2h(rho(k));

% You will have to write this function rho2h(density);

end

% Plot

figures figure(1)

plot(t,rho,’r-’);grid on;xlabel(’Time’);ylabel(’Density (slugs/ft^3)’);

figure(2)

plot(t,h,’r-’);grid on;xlabel(’Time’);ylabel(’Altitude (ft)’); %===============================================================================

Equation that needs to be converted to find h:

P= Po*((518.67-.003567*h)/518.67)^(-1+(32.17406/(1716*.003567)))

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

Code for aem2301_ps_pr_2.m

%======================================================================%

% m-script name: aem2301_ps_1_pr_2.m

% Programmer: Your name goes here

% Date created: Date you created this m-script

% Date last modified: Data of the last change to this m-script

%

% Description: This m-script plots time vs. density and time

% time vs. altitude for a rocket in flight
%=======================================================================%

% Clear memory and work space

clear all;

close all;

clc;

% Time and density history for the launch and ascent of a rocket

t = [0 10 20 30 40 50 60 70 80 90 100];

% Time in seconds since launch
rho = (1e-3)*[2.377 2.208 2.010 2.0624 2.1149...
2.1673 2.2197 2.2721 2.3246 2.3770 2.377];

% Density in slugs/ft^3

% Loop through t and density to calculate altitude

number_of_data_points = length(t);

for k=1:number_of_data_points
  
h(k) = rho2h(rho(k));
  
% You will have to write this function rho2h(density);
  
end

% Plot

%figures

figure(1)

plot(t,rho,'r-');grid on;xlabel('Time');ylabel('Density (slugs/ft^3)');

figure(2)

plot(t,h,'r-');grid on;xlabel('Time');ylabel('Altitude (ft)');
%===============================================================================

%Equation that needs to be converted to find h:

% P= Po*((518.67-.003567*h)/518.67)^(-1+(32.17406/(1716*.003567)))

Code for rho2h.m

function h = rho2h(density)

% h is the variable that is being returned. h is the altitude

% Equation that needs to be converted to find h:

% P = Po*((518.67-.003567*h)/518.67)^(-1+(32.17406/(1716*.003567)))

%===================== The converted equation =============================

Po = 2.377*(1e-3); % Po is the density at t = 0
P = density; % P is the density at some altitude

h = (518.67 - (P/Po)^(1/(-1+(32.17406/(1716*.003567))))*518.67)/.003567;

end

The results

Add a comment
Know the answer?
Add Answer to:
This problem will introduce you the MATLAB (if you have not used it before). In this...
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
  • The purpose of this problem is to become familiar with the use of MATLAB. Consider the...

    The purpose of this problem is to become familiar with the use of MATLAB. Consider the continuous-time function x(t) 2e0.5sin(87t)u(t), where u(t) is the unit step function. a) (10 points) Design a MATLAB routine to plot x(t) from t -5 to t = 5 using 10, 100, and 1000 equally spaced samples. The following MATLAB code fragment suggests how this 11. can be done (using 1000 equally spaced samples). Note that the function provided by MATLAB, but can be easily...

  • MATLAB question and submit hardcopy meeting. Also print out are able to create. a of your...

    MATLAB question and submit hardcopy meeting. Also print out are able to create. a of your MAILAB function with solution you Fird: caleulatel altude as a duning hight loN 0.05kg Mde- mg/m F- 29. while loops The flight of a model rocket of mass 0.05 kg can be modelled as follows. During the first 0.15 s the rocket is propelled up by the rocket engine with a force of 16 N. The rocket then flies up slowing down under the...

  • I want the math lab code for theses problems in a unique way

    I want the math lab code for theses problems in a unique way Theory A projectile is launched from point A up an incline plane that makes an angle of 10 with the horizontal. The mountain is 6,000 m high. Vo 10° Figure 1: Flightpath of a projectile. If we neglect the air resistance, the flight path of a projectile launched at an initial speed vo and an angle θ of departure relative to the horizontal is a parabola (see...

  • Please help me correct my MATLAB script code for this problem, thank you!! A projectile PA is launched from point A towards the east with an initial launch velocity voa and an initial...

    Please help me correct my MATLAB script code for this problem, thank you!! A projectile PA is launched from point A towards the east with an initial launch velocity voa and an initial lauw angle of 0x. The impact point of the projectile Pa is a point B in a valley with an ordinate, yon, located below the clevation of point A. The launch from point A is instantaneously detected at point B, and a counter projectile P launched simultaneously...

  • In MATLAB At time t=0 when a rocket's engine shuts down, the rocket has reached an...

    In MATLAB At time t=0 when a rocket's engine shuts down, the rocket has reached an altitude of 500 m and is rising at a velocity of 125 m/s. The height of the rocket as a function of time is 9.8 h(t)= t? +125t+500 for t > 0 2 Create a time array t from O sec to 30 sec with an increment of 1 sec and a corresponding array for the height h. Plot the height of the rocket...

  • by matlab programm please 3. A rocket is launched straight into the air with initial velocity...

    by matlab programm please 3. A rocket is launched straight into the air with initial velocity 200 ft/s. Assume the launch is instantaneous. How high will it go, and how long will that take (use time increments of 0.01 seconds)? G-- 32.2 ft/s, Ho-0 (the ground) V(t)-Vo+ g t H(t) Ho+ Vot+½gt The rocket deploys a parachute after 9 seconds and descends at a constant rate of 20 ft/sec. How long does it take to reach the ground? Plot the...

  • modify this code is ready % Use ODE45 to solve Example 4.4.3, page 205, Palm 3rd...

    modify this code is ready % Use ODE45 to solve Example 4.4.3, page 205, Palm 3rd edition % Spring Mass Damper system with initial displacement function SolveODEs() clf %clear any existing plots % Time range Initial Conditions [t,y] = ode45( @deriv, [0,2], [1,0] ); % tvals yvals color and style plot( t, y(:,1), 'blue'); title('Spring Mass Damper with initial displacement'); xlabel('Time - s'); ylabel('Position - ft'); pause % hit enter to go to the next plot plot( t, y(:,2), 'blue--');...

  • This is a MATLAB Question. Below is my base code for a Fourier Series of a...

    This is a MATLAB Question. Below is my base code for a Fourier Series of a half triangle wave. So I am being asked to isolate the first 8 components so that only those first 8 components of the half triangle function are calculated by MATLAB fft function, and then afterwards I am asked to do the same thing but with the first 20 components rather than the first 8. How do I isolate the first x number of components...

  • (15 points) This problem is related to Problem 3.7 in the text. consider reviewing Section 3.2.1.1....

    (15 points) This problem is related to Problem 3.7 in the text. consider reviewing Section 3.2.1.1. The following MATLAB program plots the function v(t) = 5 cos(300 - 24t) + 2 sin (600 - 2x + ) t = 0: step :Tmax; V = 5* cos(2pi"300"t) + 2 sin(2"pi*600*t + pi/2); plot(t,v) xlabel('time (seconds)') ylabel('signal v(t)) axis([xmin,xmax,ymin,ymax]) What is the period of the signal v(t)? Suppose that we want to produce a plot that covers exactly 4 periods and has...

  • Signals and System: MATLAB code provided? Begin with the MATLAB script named lab4.m as follows. You...

    Signals and System: MATLAB code provided? Begin with the MATLAB script named lab4.m as follows. You will modify this example code to cover each of the parts of this lab. You must always carefully document and include appropriate comments in any MATLAB code. & starting point for Lab#4 % LAPLACE TRANSFORM %---------- clear all; close all; -------------------- s = tf('s'); sys = 1/(5+1); & define H(s) for a dynamic system named sys ---------------- figure(1); bode (sys); % plot magnitude and...

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