Tutorial Set 1

2
| University of Dar es Salaam | Department of Electronics and Telecommunications Engineering | ________________________________________________________________________________ | TE 412 Introduction to Wireless Communications | Christine Mwase | 10/03/2014 | Tutorial Set 1 1. Start MATLAB and make the command window active. Then clear the command window. a. Issue a command at the command window to show the path name of the current directory. b. Clear the entire command history window. Calculate and display the value of cos(π/4) at the command window. Check what happens in the command history window. c. Open the help menu and choose Matlab help. Try to expand and collapse some topics on the help navigation pane. Quit the help window. 2. Variables. a. Get help on the diary command. Practice using the command by saving your work session in a file my_session.txt. Check that it works by displaying the contents of your file using the Matlab editor. b. Show which variables exist in your workspace. Save the existing variables in a file my_variables.mat. Clear all the variables from the workspace and check that they have been cleared by displaying the existing variables again. Retrieve your saved variables from my_variables.mat and show them at the command window. c. Create the following variables: x = 40; y = cos(π/4); z = 0.25. Find their average and store the result in a new variable a. What is the value of a? Find their sum and store the square root of their sum in a variable b. What is the value of b? 3. Create the following vectors using MATLAB: a. A row vector, triomult, with numbers that are multiples of 3 ranging from 33 to 2010. b. A vector, triomult_squared, containing the square of the elements in triomult. c. Determine how many elements there are in the above vectors. 4. Given matrices A and B defined by - = = 9 19 9 3 78 32 7 54 6 65 15 6 3 21 34 23 ; 32 24 16 12 24 20 12 10 24 18 8 6 18 15 6 5 B A a. Using the colon operator, display row 4 of matrix A. Display column 2 of matrix B. b. Given that [c,d] = size(A*B(:,2)), find c and d. What do they represent? What is the value of length(size(A*B(:,2)))? 5. Given y(x) = sin(x)/x where 4π x 4π for steps of x values of 0.05, find the minimum and maximum values of y and the values of x at which these values occur. 6. Given the following polynomials p(x) = x 4 – 12x 3 + 25x + 116 q(x) = x 5 + 2x 2 + 3x + 4 i. Find the roots of p(x) = 0 and q(x) = 0. ii. Find the coefficients of a(x) = p(x) * q(x). What is the order of a(x)? iii. Write down the expression for b(x) if b(x) = p(x) / q(x).

description

Tutorial 1

Transcript of Tutorial Set 1

Page 1: Tutorial Set 1

| University of Dar es Salaam | Department of Electronics and Telecommunications Engineering |

________________________________________________________________________________

| TE 412 Introduction to Wireless Communications | Christine Mwase | 10/03/2014 |

Tutorial Set 1

1. Start MATLAB and make the command window active. Then clear the command window.

a. Issue a command at the command window to show the path name of the current

directory.

b. Clear the entire command history window. Calculate and display the value of cos(π/4)

at the command window. Check what happens in the command history window.

c. Open the help menu and choose Matlab help. Try to expand and collapse some topics

on the help navigation pane. Quit the help window.

2. Variables.

a. Get help on the diary command. Practice using the command by saving your work

session in a file my_session.txt. Check that it works by displaying the contents of your file

using the Matlab editor.

b. Show which variables exist in your workspace. Save the existing variables in a file

my_variables.mat. Clear all the variables from the workspace and check that they have been

cleared by displaying the existing variables again. Retrieve your saved variables from

my_variables.mat and show them at the command window.

c. Create the following variables: x = 40; y = cos(π/4); z = 0.25. Find their average and

store the result in a new variable a. What is the value of a? Find their sum and store the

square root of their sum in a variable b. What is the value of b?

3. Create the following vectors using MATLAB:

a. A row vector, triomult, with numbers that are multiples of 3 ranging from 33 to 2010.

b. A vector, triomult_squared, containing the square of the elements in triomult.

c. Determine how many elements there are in the above vectors.

4. Given matrices A and B defined by

=

=

91993

7832754

665156

3213423

;

32241612

24201210

241886

181565

BA

a. Using the colon operator, display row 4 of matrix A. Display column 2 of matrix B.

b. Given that [c,d] = size(A*B(:,2)), find c and d. What do they represent? What is the

value of length(size(A*B(:,2)))?

5. Given y(x) = sin(x)/x where 4π ≤ x ≤ 4π for steps of x values of 0.05, find the minimum and

maximum values of y and the values of x at which these values occur.

6. Given the following polynomials

p(x) = x4 – 12x

3 + 25x + 116 q(x) = x

5 + 2x

2 + 3x + 4

i. Find the roots of p(x) = 0 and q(x) = 0.

ii. Find the coefficients of a(x) = p(x) * q(x). What is the order of a(x)?

iii. Write down the expression for b(x) if b(x) = p(x) / q(x).

Page 2: Tutorial Set 1

| University of Dar es Salaam | Department of Electronics and Telecommunications Engineering |

________________________________________________________________________________

| TE 412 Introduction to Wireless Communications | Christine Mwase | 10/03/2014 |

7. If -1, -2 and -3±4j are the roots of the polynomial a(x), what is the order of a(x)? Write down the

expression of a(x).

8. Write the necessary statement(s) to find x(1), x(2) and x(3) given that x(0) = 0.5 and

( )335)(

))((

))(()()1(

234++−=−=+ xxxxfand

nxfdx

d

nxfnxnx

.

9. Create a script file `test1.m' in which MATLAB successively performs the following:

Delete all variables from the memory.

Define a row vector x = 1:0.1:10.

Calculate y = sin(x) - cos(x).

Plot y as a function of x.

For later use, add comments to your script file so that it can be easily understood.

Save the file.

Test the script file and, if necessary, debug the file.

Call up the commentary of the file with >> help test1.

10. Create a function file `test2.m' in which MATLAB for an arbitrary input x calculates and

displays output y on the screen.

Calculate y = sin(x) - cos(y).

Plot y as a function of x.

For later use, add comments to your script file so that it can be easily understood.

Save the file. Ensure that the function name is the same as the corresponding filename.

Test the function file with a = 1:0.1:10 and, if necessary, debug the file.

Call up the commentary of the file with >> help test2.

Explain the difference between a script file and a function file.

11. Find out using MATLAB's in-built help browser and using the Mathworks website

(www.mathworks.com), how to work with flow control structures in MATLAB. The Mathworks

site has a lot of tutorials for beginners as well as professionals on the use of MATLAB for

different application areas. Explore the site to upgrade your MATLAB knowledge and skills.

12. Call the help browser from the command prompt in the command window. Under the demos tab,

expand the Blocksets menu, then expand within it the Communications submenu. Under

Modulation run the GMSK vs. MSK demo. Quit the helpbrowser.