Starting from:

$30

EE384-Lab0 Introduction to MATLAB Solved

Problem 1:  

1.1) What is the result of:

a)                   a+b

b)                  a*b

c)                   a.*b where ‘a’ and ‘b’ are column vectors  

  

1.2) Repeat 1.1 but with ‘a’ as a matrix

  

Turn in your answer.

Problem 2: 

Plot following functions in the same plot (overlay)

𝑦1 = cos(𝑡) 𝑦2 = sin(𝑡)

where ‘t’ is a vector from 0 to 50 with the increasing step:

a)       1

b)      0.01

Do the signals look smoother when we reduce the increasing step? Turn in your answer, plots, and codes.

Problem 3: 

Write a program to solve the system of equations of three variables using the matrix inverse method. The program should include user prompt to input equation coefficients. The general form of a three-variable equation is  𝑎𝑥 + 𝑏𝑦 + 𝑐𝑧 = 𝑑. Assume that the users have to give the coefficients in the order ‘a’, ‘b’, ‘c’, and ‘d’. Test your program with the following system of equations:

2𝑥 + 3𝑦 + 𝑧 = 3

𝑥 + 3𝑦 − 𝑧 = 6

2𝑥 + 2𝑦 = 7

Turn in your code and result from the Matlab command window.  

Hints: Note that from Linear Algebra theory, you can solve the system of equations using matrix inverse method by the following steps:

Step 1: Rearrange the equations so that all of them have the form of 𝑎𝑥 + 𝑏𝑦 + 𝑐𝑧 = 𝑑

Step 2: Write the equations in matrix form 𝐴 ∗ 𝑡 = 𝑏

Step 3: The result is 𝑡 = 𝐴−1 ∗ 𝑏  

𝐴−1 is the inverse matrix of A and could be computed in Matlab by using the command inv(A).

Problem 4: 

Write an M-file program to calculate:

  

where ‘log’ is the natural logarithm function, ‘sign’ is the signum function.  

The program must include a user prompt to input the parameter ‘µ’ and input ‘x’. Note that ‘x’ can be either a scalar number or a vector. The above equation shows the input-output characteristic of a µ-law compressor used in pulse-code modulation (PCM).

Test your program by plotting ‘y’ according to ‘x’. Let µ=255 and ‘x’ is a vector changing from 0 to 1 with the increasing step 0.01. Turn in your code and plot. Keep a copy of your code, you will need it later.

 

More products