Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

EGR324L: Linear Systems and Signals Lab Lab 2: Vector Manipulations and Graphical Plotting Objective To learn Matlab operations on vectors, including vector import and export procedures. To get...

1 answer below »
EGR324L: Linear Systems and Signals La
Lab 2: Vector Manipulations and Graphical Plotting
Objective
To learn Matlab operations on vectors, including vector import and export procedures. To get familiar with Matlab’s graphical plotting facilities.
Background
Matrix Manipulation
The basic objects manipulated by Matlab are 2-dimensional matrices. A vector is a special cases of a matrix, which has only one row or one column. To avoid confusion, a vector of N elements is defined, for this class, as a matrix of N by 1 elements, that is, a matrix of N rows by 1 (one) column. In case an operation only takes a row vector, a transpose operation should be inserted wherever appropriate to accommodate the function.
You may discover that Matlab is extremely powerful in doing matrix manipulations, as a scalar operation is applied to all elements of a matrix "in parallel". This eliminates almost completely the need of iterative operators (for and while loops) commonly employed in conventional programming languages.
For instance, to calculate s[n] = sin (27Ï€n/1000) for n = 1, ..., 1000, we write the following program in Pascal:
for n := 1 to 1000 do s[n] := sin(2 * PI * n / 1000);
In Matlab, we could use a for loop,
for n = 1:1000, s(n) = sin(2 * pi * n / 1000); end
Or simply
s = sin(2 * pi * (1 : 1000) / 1000)
Since Matlab programs are interpreted (not compiled), for loops and while loops are very inefficient. They should be avoided whenever possible.
Data Import and Export
Data generated by other programs can be imported into Matlab with the load command. The raw data can be in an ASCII file. On the other hand, Matlab may also generate data to be processed by other programs. The command to be used in this case is save.
To export vector x (N by 1 matrix) to a file called x.dat in ASCII, use command
save x.dat x /ascii
It is considered a good practice to assign the same name to the variable and the file, like in this example, although both names can be a
itrary.
To import data from a file called x.dat in ASCII, type
load x.dat /ascii
The content of the file will be loaded to variable x. If the file contains N rows, and each row contains exactly one number, x will be a N by 1 matrix, namely, a vector.
Graphical Plotting in Matla
Matlab supports graphical plotting on both computer screen and on a printer. The command for plotting on the screen is plot, which is used in a number of formats.
plot(y)
Plot vector y versus their indices.
plot(x, y)
Plot vector y versus vector x with the default line type.
plot(x, y, ’’)
Plot vector y versus vector x with specified . Possible line types include line, point and color specifications which are given in the Matlab book as well as in the on-line help.
Command plot can also take other forms for its argument list. Please see the Matla
ook for a detailed discussion of this command.
Several other commands are used to help generating the desired plot. They include: axis, hold, title, xlabel, ylabel, text, gtext, etc. Some of them will be needed for this assignment. Please see the Matlab book, or use on-line help for details of these commands.
Use command print to obtain a high quality hard copy of the cu
ent screen plot.
Preparation
Please read the following topics from the Matlab book. Instructions will also be given during the lab session.
· Built-in operators for vector manipulation
:(range selector), ’(transpose), +, -, *, /, ^, .*, ./, and .^.
· Language constructs
for, while, end, if,
eak.
· Commands to generate graphical plots
plot, bar, stairs, title, xlabel, ylabel, text, gtext, hold, axis, grid, clg and print.
· Built-in functions
em, round, ceiling, floor, fix
Do not be frustrated if you do not understand some of the material of linear alge
a -- just skip it.
Problems
(1) Let x[n] = n, for n = 1,…, 8. Calculate and plot , for n=1, ..., 8.
(2) Compute and plot x[n] = for n = 1,..., 1000.
On the same graph, plot e-0.003n and -e-0.003n with another color or line type. Electronically mark the curves to identify each individual one.
(3) Using Matlab to plot the drawing illustrated below. You only need to plot along the black lines.
(4) Given x[n] = sin(n/100), generate and plot the following vectors for -628 < n < 628.
a. Generate x[n], y[n] = 0.5·x[2n] and z[n] = 0.2·x[5n]. Plot all three on one graph.
. Generate x[n], v[n] = x[n - 100] and w[n] = x[n + 150]. Plot all three on one graph.
Report
(1) A script (.m) file should be created for each problem.
(2) Make sure you show only important intermediate results, response from Matlab should be suppressed for obvious or tedious operations (for instance, assign a constant to a variable).
(3) All script files should contain comments detailed enough for understanding your program.
(4) Turn in all .m files, the diary created in (4), and all graphical plots.
(5)    Write a paragraph about questions and confusions you have experienced about this experiment.

EGR324L: Linear Systems and Signals La
Lab 1: Introduction to Matlab and Complex Number Manipulation
Objective
To learn how to access Matlab and to get familiar with basic operation procedures of
Matlab. To review numerical calculation of complex numbers using Matlab.
Background
Matlab by MathWorks Inc., is a computing environment specially designed for matrix computations. It has widely used in the study of circuits, signal analysis and processing, control systems, etc. Its large li
ary of built-in functions and graphical capability makes it a valuable tool in Engineering education and research.
Matlab has an interactive mode, in which user statements are interpreted immediately as they are typed. Alternatively, a program can be written in advance using a text editor, saved as disk files, and then executed in Matlab.
Preparation
Although the basic objects manipulated by Matlab is matrix, we only deal with complex number (scalars) in this assignment.
Please read the following topics from Matlab manual or from the optional textbook,
" The Student Edition of MATLAB ". Your instructor will also give instructions during the lab session.
· command mode operation
· on-line help
· script editing and execution
· command language
constants, variables, expressions. assignments, m-files, function calls, function definitions, and comments.
· Matlab commands
diary, echo, type, !, pause, quit, who and whos
· predefined variables
ans, i, j and pi.
· built-in operators
+, -, *, / and ^
· built-in functions
abs, angle, clear, conj, cos, exp, imag, real, sin and sqrt.
Problems
(1) Express the following in both polar form and rectangle form using Matlab.
(2) Find roots for the following equations using Matlab.
a. 3.72x2 + 2. 1x + 8.25 = 0
. 4x2 + 25x - 56 = 0
(3) A complex number y = a + jb is perpendicular to that of x = c + jd if a = -d and b = c. Define a function y = perp(x), which takes a complex number x as input, and returns a complex number y, which is perpendicular to x.
(4) Using function perp defined in (3), find complex numbers perpendicular to
espectively.
Report
(1) A script (.M) file should be created for each calculation. They may be named prob_1_a.m for problem 1 (a). etc.. Script files for user function definitions should have their proper names based on functionality.
(2) Make sure you show only important intermediate results, responses from Matlab should be suppressed for obvious or tedious operations (for instance, assign a constant to a variable).
(3) All script files should contain comments detailed enough for understanding your program.
(4) A session diary that records the execution of all script files should be created. The following is a sample session diary for this experiment.
prob_1_a
(execution of code for Problem 1(a))
prob_1_
(execution of code for Problem 1(a))
(5)    You should turn in all m files along with the file that records the diary session. This file may be named lab_1. Specifically, you need to turn in the following files for this experiment.
prob_1_a. m prob_l_b.m prob_1_c.m
prob_2_a.m prob_2_b.m
perp.m
prob_4_a.m prob_4_b.m prob_4_c.m
lab_1
Answered Same Day Sep 08, 2021

Solution

Intakhab answered on Sep 10 2021
161 Votes
EGR324L: Linear Systems and Signals La
Lab 1: Introduction to Matlab and Complex Number Manipulation
Problem 1 (a)
Matlab code
Z=((1-i*(sqrt(3))).^3)+i*(1+i)*exp((i*pi)/6);%complex numbe
A=abs(Z) %gives absolute value
theta=angle(Z) %gives angle
x=A*(cos(theta)+i*(sin(theta))) %polar form
Solution
Problem_1_a
A =
9.3732
theta =
3.1025
x =
-9.3660 + 0.3660i
Problem 1 (b)
Matlab Code
Z=((2-i*((6)/(sqrt(3))))/(2+i*((6)/(sqrt(3)))))/((exp(i*pi/3)-1)/(1+i*(sqrt(3)))) %complex numbe
A=abs(Z) %gives absolute value
theta=angle(Z) %gives angle
x=A*(cos(theta)+i*(sin(theta))) %polar form
Solution
problem_1_
Z =
-2.0000
A =
2.0000
theta =
3.1416
x =
-2.0000 + 0.0000i
Problem 1 c
Matlab code
Z=((sqrt(3)+i)*2*(sqrt(2))*exp(i*pi/4))^0.6 %complex numbe
A=abs(Z) ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here