

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Lab; Professor: Paris; Class: Lab for Lecture 001; Subject: Electrical & Computer Enginrg; University: George Mason University; Term: Unknown 1989;
Typology: Lab Reports
1 / 2
This page cannot be seen from the preview
Don't miss anything!


ECE 201: Introduction to Electrical Engineering II Prof. B.-P. Paris Lab 3: Programming in MATLAB
The objective of this lab is to write a Matlab script M-file that implements the functionality described below. Store your program in a file named Lab3.m.
Choose from the following menu:
Enter complex number in polar form (1) Enter complex number in rectangular form (2) End program (0)
Choice (0, 1, 2)? :
Read the user’s input and proceed according to his choice. Should the user enter anything other than 0 , 1 , or 2 , display an error message and redisplay the menu.
degrees (1) redians (2)
Choice (1, 2): Allow the user to continue from this dialog only after he selected either 1 or 2. Proceed to prompt the user for the magnitude and phase of the first complex number. Check that the magnitude is positive. Construct a complex number C1 from the user’s input. Be sure to interpret the phase according to the preference expressed by the user. Don’t forget to convert to radians if the user indicated a preference for degrees. Display the complex number C1 in rectangular coordinates, e.g., display a line like C1 = x + j y where x and y are the the real and imaginary parts of C1. Prompt the user for a second complex number and store it as C2. Ensure that C1 and C2 are different. Display the number C2 in rectangular form.
degrees (1)
redians (2)
Choice (1, 2): Allow the user to continue from this dialog only after he selected either 1 or 2. Compute the magnitude and phase of each of the two numbers and display the result like this C1 has magnitude r1 and phase phi C2 has magnitude r2 and phase phi where r1, r2, phi1, phi2 are the magnitudes and phases you computed.
plot(y) xlabel(’Real’) ylabel(’Imaginary’) grid
Explain what you see.
For your final report, turn in your well-commented Matlab program Lab3.m. Attach a plot that shows C3.^nn with an explanation of what you see. Also, execute your program once while capturing output to a diary file and attach the diary file. The report is due one week after this lab.