matlab hw 2

advertisement
ENME202/ENAE202
Computing Fundamentals for Engineers
Matlab Homework 2
Problem overview
An important area of mechanical engineering is the analysis of vibrations. When studying vibrations, we
often analyze a position x (maybe the tip of a robotic arm, or the height above ground of a vehicle, etc.) and
how it varies in time. The equation describing linear vibration of a simple system can be expressed as:
x(t) = x(0) eλt
where λ is a complex number that determines the behavior of the system, and x(0) is the initial position of
the vibrating element. The l term The imaginary part of λ is the angular frequency, while the real part
describes exponential growth (positive real part) or decay (negative real part).
In this homework, let’s assume that λ is the root of the equation:
β1/4λ2 + (α1β − α2)λ + α3β0.6 = 0
where α1, α2 and α3 are fixed parameters that we can’t change, and β is a design variable that we are free to
choose. To select the desired value of β, we need to see how the root λ changes when we vary β. Since λ is
complex, we typically plot λ in the complex plane for a whole range of β values – this plot then looks like
a line in the complex plane (a single root is a point, but since we vary β we get a line as this root moves
around). As you will learn when studying vibrations and control systems, the resulting graph is called a
“root locus” plot because it tracks the roots of the dynamical equation as a selected parameter of the system
changes. Remember that the complex plane is simply a cartesian coordinate system where the x-axis
describes the real part of a complex number, and the y-axis describes the imaginary part of the complex
number. For example, the number 1+2i could be plotted in the complex plane as follows:
p_real = 1;
p_imag = 2;
plot(p_real, p_imag, 'ko')
grid
axis([-3 3 -3 3])
% plot p = 1+2i in the complex plane
% add a grid
% change axis limits
% Draw axis lines (we did not discuss the line() function
% in class, and you are NOT responsible for this topic):
line([0 0], ylim); % draw x-axis
line(xlim, [0 0]); % draw y-axis
ENME202/ENAE202, University of Maryland
Assignment
Write a script plotLambdaRoots.m which accomplishes this task. Your script should assume that numerical
values for the parameters alpha1, alpha2, and alpha3 have been defined in the workspace, and should
compute and plot the locations of the roots λ for every value of β in the range 0.01 to 1 in steps of 1e-4.
You must use arrays for this, like in the studio – don’t use a “loop”, even if you already know how!
Note that you’ll need to solve the quadratic equation for λ, which will yield a pair of complex conjugates.
Because the magnitude of the imaginary part of λ is thus the same for both roots, we only need to keep track
of (and plot) the root with a positive imaginary part. Since the coefficients of the quadratic equation are
functions of β, using Matlab’s array arithmetic appropriately will generate an array of corresponding roots.
Keeping in mind that the complex plane uses the real part of a complex number as the horizontal coordinate
and the imaginary part as the vertical coordinate, use the plot command to plot the array of roots for all
values of β as a blue line within the complex plane.
When analyzing vibrations, it is interesting to find two special solutions: (i) the solution with the largest
imaginary part (i.e., highest angular frequency); and (ii) the solution with zero real part (i.e., which neither
grows nor decays in time). Your script should find the values of β corresponding to both of these, and print
those values to screen. It should also print the imaginary parts of λ for both of those β-values. Finally, it
should plot a red circle on the largest-imaginary-part root, and a black square on the zero-real-part root.
To make sure that your script runs properly, test it yourself using the exact technique we will use when
grading:
clear; close all
alpha1 = 3; alpha2 = 1.2; alpha3 = 4;
plotLambdaRoots
which should produce a plot (with a curve, a point with a red circle, and a point with a black square), and
the following printout:
beta_maxImag =
0.7677
lamIm_maxImag =
1.8164
beta_zeroReal =
0.4000
lamIm_zeroReal =
1.7037
Your script should not produce any other output than this.
ENME202/ENAE202, University of Maryland
Download
Random flashcards
Arab people

15 Cards

Radioactivity

30 Cards

African nomads

18 Cards

Create flashcards