Write a matlab script to calculate the speed of the rocket

Assignment Help MATLAB Programming
Reference no: EM131667246

Assignment

PART A: Functions of Two Parameters

QUESTION 1

Create a function to solve a generic 3 x 3 system of equations with a column vector representing 3 different constants.

a) Find the determinant of A to establish if the input coefficient matrix is invertible. If the determinant is zero then the matrix is not invertible.

b) Use an IF statement based on the result of a) to decide whether or not to proceed with a solution based on ONE of four methods.

c) Using the AX = E equation and ONE of four of the following methods, solve the 3 x 3 system:

i. using Gauss-Jordan reduction procedure (use RREF)

ii. using A-1B % find A-1, the inverse matrix, using INV or A^-1

iii. using A \ B % left hand Gaussian Elimination division

iv. using [B'/A']' % right hand division

d) Create code in your function to return a 3 x 1 vector called X. [4 Marks]

QUESTION 2

Solve the following problem with the function created in question one:

927_Matrix.jpg

a) using your function from a) find the solution (matrix X which is a 3 x 1 matrix).

b) Run your function at command-line level and check the solution matrix, X, with AX = E.

c) Evaluation of Solution:

Please use an inequality (a Boolean expression) to evaluate the accuracy of your solution.

Explanation of the NORM and EPS Functions

When passed a difference vector (A*X - E), NORM gives the 2-norm or Euclidean Distance (or length) from the origin to the difference vector.

>> M = [1 2 3];

>> norm(M,2)
ans = 3.7417
>> norm(M)
ans = 3.7417

EPS (Epsilon), a MATLAB built-in function, with no arguments, is the distance from 1.0 to the next larger double precision number, that is EPS with no arguments returns 2^(-52).

>> eps
ans = 2.2204e-16

PART B: Graphing in MATLAB

Complete the MATLAB code wherever required for the following 2D MATLAB graph functions:

QUESTION 1

STEM graph displaying the function f(t) = et/4 sin t f or the interval 0 ≤ t ≤ 2π

t = linspace(0,2*pi,150);
exponent = ...;
a=exp(exponent*...).*(sin(t));
stem(...,...)
syms t
f = exp(exponent*...).*(sin(t));
grid on

xlabel '...'
ylabel('...');

title_handle = title(['Stem Plot of ' ' '$' latex (f) '$'],...

'interpreter','latex'); set(...,'fontsize',16)

QUESTION 2

COMPASS graph displaying the function

z = cos θ + j sin θ for the interval -π ≤ θ ≤ π

theta=-pi:pi/...:pi
rx=cos(...)
ry=sin(...)
z= ... + ...
compass(...)

QUESTION 3

a) FILL graph displaying the function r2 = 10cos 5t f or the interval 0 ≤ t ≤ 2π

HINT: make r the subject and use the trigonometric identities to find x and y:
x = r cos t, y = r sin t

t = linspace(0,2*pi,...);
r=sqrt(...(...));
x=...
y=...
fill(x,y,'c')
axis('square')

b) Try altering the function, r2, to increase the number of "petals" from 10 to 20. Save the MATLAB figure as a PNG file.

QUESTION 4

SEMILOGX graph displaying the function x = e-t, y = t, f or the interval 0 ≤ t ≤ 2π

HINT: fill out the ellipses with some MATLAB Code.

t = linspace(0,2*pi,200);
x = exp(-t);
y1 = ...;
semilogx(...,...), grid on

QUESTION 5

LOGLOG graph displaying the function x = et, y = 100 + e2*t f or the interval 0 ≤ t ≤ 2π

t = linspace(0,2*pi,200);
x = exp(t);
y = 100+exp(...);
loglog(...,...), grid

Complete the MATLAB code wherever required for the following special MATLAB graph functions:

QUESTION 6

EZPLOT graph for the following functions:

x = cos (3t),
y = tsin (3t),
z = √3t

a) ezplot3('...','...','...')

Increase the number of loops from 3 to 6:

b) ezplot3('...','...','...')

QUESTION 7

FPLOT graph to display the following function

y = 4x2 + 8sin (3x) f or the interval -7 to 7

fplot('...',[...,...])
xlabel x
ylabel ...
title '...'

PART C: Flight Path of a Model Rocket

Scenario

The flight path of a model rocket, of mass 0.05 kilograms, can be modelled in MATLAB using simple equations and graphs. During the first 0.25 seconds (s) the rocket is propelled upward by the rocket engine with a force of 25 N. However, the rocket runs out of fuel before reaching its peak hence, the engine stops.

The rocket then flies up carried by its own momentum while slowing down under the gravity force (g = 9.81metres/s/s) at a constant deceleration.

Once it reaches the peak of its flight path the rocket starts to fall down. At a downward velocity of 20 m/s the parachute opens instantly so the velocity stays constant (that is 20 m/s) with an acceleration of zero until it hits the ground.

The rocket is assumed to be a particle that moves along a straight line in the vertical plane. For motion with constant acceleration (a) along a straight line, the velocity and position as a function of time (t) are given by the equations:

1. v(t) = v0 +at

2. h(t) = s0 + v0t + ½at2

where v0 and s0 are the initial valocity and position (hight) respectively

MATLAB Task

Write a MATLAB script to calculate the height (metres) and the speed (metres/s) of the rocket over flight-time.

Plot these results against time using two graphs.

NOTE: the speed metric should include the direction (+up / -down) as well as metres/s information.

Instructions to create this MATLAB script:

o Flight path of the rocket is divided into three segments (see below for detailed description)

o Each segment is calculated with either WHILE or FOR-END loops

o In every iteration, of a loop, time is incremented by Dt = 0.01

o Separately graph the results of height (m) and velocity (m/s)

o Annotate your plots inside your script or with the Plot Editor

o The accuracy of the h(t) and v(t) results depends on the size of the time increment, Dt

o Set n to be no bigger than 50,000 to avoid infinite loops

o Make use of the MATLAB Code frame on page 15 to complete the script

Detailed Description of the Three Segments of the Rocket's Flight-time

a) Segment One

The first 25 seconds when the rocket engine is firing and the rocket is moving upward with constant acceleration. Determine the acceleration by referring to the mass acceleration diagram and noting the forces acting on the rocket. Then fill out the ellipses of the summative force equation with the appropriate forces, then solve it for a.

Next work out v(t) and h(t) from the previous equations, 1 and 2.
v0 and s0 both equal zero in this case

In the MATLAB program this segment starts at t = 0 and loops while t < 0.25s. At t = 0.25 s time, velocity and height become t1, v1 and h1.

b) Segment Two

The motion of the rocket from when the rocket engine stops firing, or runs out of fuel, until the parachute opens. The rocket moves with a constant deceleration of g. Now the equations for v(t) and h(t) alter to become:

v(t) = v1- g(t - t1) and h(t) = h1 + v1 (t - t1) - ½g (t - t1)2

The iteration continues until the velocity is 20 m/s but note that as we are plotting speed against time we really need to consider direction too so that this is really negative (-)20 m/s (v2) since the rocket is falling downwards, that is, in a negative direction. At the end of this segment two, the time, velocity and height become t2, v2 and h2.

c) Segment Three

The motion of the rocket from when the parachute opens until the rocket hits the ground. The rocket now moves with a constant velocity of -20m/s but zero acceleration. Now the equations for v(t) and h(t) alter to become:

v(t) = -20 and h (t) = h1 - vchute (t- t2)

The loop continues to iterate so long as height is > zero.

PART D: Einstein's Special Relativity

According to special relativity, a metallic rod of initial length L, when at rest, will when travelling at a velocity v through outer space, shrink by an amount δ(meters) according to the following formula:

δ = L [1 - √{1 - (v2/c2)}

where c = 300 x 106m/s (the speed of light)
L = initial length of object in meters when at rest
v= velocity of object in meters/ second

Imagine a rod with an initial length of 30 metres travels through outer space and reaches 90% of the speed of light, c. At this time how long is the rod?

a) define in MATLAB: c = 300 x 106, L = 30 and v = 0.90 x c

b) With the above formula calculate δ(meters).

c) Using δ find the overall length of the rod in metres and hence, answer the question: "At this time how long is the rod?"

PART E: Moment Magnitude Scale

The Moment Magnitude Scale (MMS), MW, measures the total energy released by an earthquake and is represented by the following formula:

MW = (2 log10 M0 / 3) - 10.7

Where M0 = size or magnitude of the seismic moment in N · m (107 dyne - cm) and the subscript W = mechanical work accomplished

In this question you need to determine how many times more energy was released from the Great Chilean earthquake on 22 May 1960, which was the largest earthquake ever recorded in the world with a 9.5 rating on the MMS and the famous Canterbury earthquake which occurred in NZ on 22 February 2011 with a MMS rating of 6.3.

a) Define in MATLAB : MW_Canterbury = 6.3 and MW_Chile = 9.5 using variable names of your own choice for the two quakes.

b) Make M0 the subject of the formula above and write a simple script or function to calculate the energy released from one earthquake. Use a reasonable value for MW to test your script, for example, a value between 3 and 11.

If you write a function then make MW the input parameter and M0 the return variable in your function definition line. Then call your function at command-line level to test it with a value for MW.

c) Using your script or function from sub-part (b) work out the ratio of the energy released from the two earthquakes from part (a) and hence, answer the question: "How many times more energy was released from the Great Chilean earthquake than the famous Canterbury earthquake?"

PART F: Damped Harmonic Motion

Plotting the Amplitude of motion of Damped Harmonic Motion of a Spring- weighted Object

A mass hung below a wall-mounted spring is released and then drops before rising again in an oscillating or repetitive manner at an ordinary frequency, f (Hz). The distance or gap between the drops and rises reduces with time with a constant of proportionality of k.

Therefore, the amplitude reduces reducing from the maximum amplitude A at t0 to zero at time t. This process is called damped harmonic motion, an oscillatory or sinusoidal motion that diminishes over time. Note that small values of k cause a longer decay over a given time and larger values cause a shorter decay over a smaller time.

For damped harmonic motion the amplitude of motion is given by:

Using the above formula for amplitude of motion create a plot similar to Figure 1. Make sure that you label your graph and colour the plot in red using a solid line.

Attachment:- MAT-LAB-Assignment.pdf

Reference no: EM131667246

Questions Cloud

Compare the running time of priority queue : Write a program to compare the running time of using the Priority Queue's one-parameter constructor to initialize the heap with N items versus starting.
Calculate the gross pay of an employee : Write a program to calculate the gross pay of an employee based on the number of hours worked and rate of payment - Write a program to take two numbers
Create a use case diagram for the urp approval form system : List 2 considerations to help you define your actors at an appropriate level. List 2 considerations to help you define your scenarios appropriately.
Produce a literature review : For this assignment, you are going to locate an alternate resource that provides you with information on how to produce a literature review
Write a matlab script to calculate the speed of the rocket : Write a MATLAB script to calculate the height (metres) and the speed (metres/s) of the rocket over flight-time. Plot these results against time using two graph.
Implement efficiently the given approximation strategies : For instance, if the items have weights 0.4, 0.4, 0.6, and 0.6, you can solve the problem with two boxes. This problem is difficult, and no efficient algorithm.
Developing professional image in chosen career field : Describe three characteristics that are key to developing your professional image in your chosen career field. Support your response and include.
Does she betray hamlet at any time : Does she betray Hamlet at any time? Does she believe Hamlet when he tells her that Claudius has killed Old Hamlet? Does she betray Denmark?
Laboratory and radiology services : Scenario: You have been invited to be a member of a PI team on improving patient wait times for laboratory and radiology services.

Reviews

Write a Review

MATLAB Programming Questions & Answers

  Finite difference method

Use the finite difference method to calculate the temperature at the point specified since it is easier.

  Determine the necessary shell temperature

In a shell-and-tube heat exchanger, one fluid passes through a central tube while another fluid flows through an outer shell in the opposite direction. The purpose is to heat the fluid passing through the central tube.

  Find the integral of a function at an arbitrary location

Write a Matlab function to perform numerical integration of a set of evenly spaced data points using the trapezoidal rule

  Compute the speed of single-stage planetary gear train

Write a MATLAB function [speed] = planetary (N, emesh, first, last, arm) that computes the speed of a given link in a single-stage planetary gear train.

  Calculate and plot the error in the numerical derivative

Write a program to calculate and plot the error in the numerical estimate of the derivative.

  Create the graph using matlab functions

Create the graph, which contains a piecewise function where a line exists in the first interval, a parabola in the second interval, and the sine function in the third interval.

  Develop a simulation program

Develop a simulation program

  Create a vector in matlab

Create a three dimensional diagram of function.

  Open a named pipe and to read data from the pipe

Open a named pipe and to read data from the pipe in matlab

  Write the commands that will create the matrix

Write the commands that will create the matrix.

  Lagrange interpolating polynomial of degree

Lagrange interpolating polynomial of degree

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd