California University of Pennsylvania Department of Applied

advertisement
California University of Pennsylvania
Department of Applied Engineering & Technology
Electrical Engineering Technology
EET 310: Methods in Engineering Analysis
Computer Assignment No.1
Due Date: 10/06/2014
Maximum Group of 3
Name:
Signature:
Name:
Signature:
Name:
Signature:
Date Submitted:
Objective:
The goal of this assignment is to gain some basic knowledge of Matlab.
References:
Students are encouraged to go over the handout on Matlab (on the course’s page) and to practice along
with the tutorials on Matlab provided by Mathworks.com
Student Learning Outcomes:
At the conclusion of this practice, students should be able to demonstrate:
a-
The ability to use Matlab to solve problems
b-
The ability to manipulate data and to draw conclusions.
The problems below assume that the student did the following preliminary steps:
1- Create own folder on the N drive to save files
2- Practiced with the handout and went over the turorials on MathWorks web site.
Questions:
1One of the most encountered problems is solving simultaneous equations. The goal of this
problem is to use Matlab to solve for variables in a given system of equations:
Helpful background information:
Suppose we have the system of equations:
𝐴𝑥 = 𝐵
Then, x = inv(A)*B
Write a Matlab code that will solve for the variable x in the system of equations below.
4 22 −9 𝑥1
18
[ 11 16 31 ] [𝑥2 ] = [ 7 ]
−2 −5 8 𝑥3
62
Submit well documented Matlab code and the results.
2-
This problem deals with plotting data
Given the voltage equations:
𝑥1 (𝑡) = 10cos⁡(400𝑡) Volts
𝑥2 (𝑡) = 10cos⁡(400𝑡 + 𝜋/3) Volts
𝑥3 (𝑡) = 10cos⁡(400𝑡 − 𝜋/3) Volts
And let the independent variable, time, vary from 0 to 50 ms in steps of 0.01ms.
Do the following: (label axes and title figures correctly)
- Plot each voltage, xi(t) separately
- use subplot command to plot all three voltages on one sheet (three different graphs on one sheet)
- plot all three voltages one graph. Use the “Insert Text Arrow” feature to identify each plot.
Submit the well documented Matlab code and all plots
3-
This question deals with creating Matlab functions and making function calls.
Write a Matlab function and call it MyPower to do the following:
A- Create the function ( this question may take some time- do your research.)
Given the complex current and complex voltage, the function calculates the real power, reactive power,
the apparent power (complex power) and the power factor.
The function has two inputs (current and voltage) and four outputs (as mentioned above.)
Save the function
B- Function Call
Write a Matlab code to do the following steps:
a-
get user input of the current – make it user friendly
b-
get user input of the voltage - make it user friendly
c-
make the function call
d-
display the returned data (clearly)
Test your code with the following data:
I = 25 + j 18.5 Amps
V = 200 + j 10 Volts
Notice, S (complex Power) is:
S = VI*
P is the real power,
Q is the reactive Power
Submit the well documented Matlab code with results
4-
This Question deals with Menu command and the switch / case structure.
Write a Matlab code to do the following:
- display a menu of 4 choices as follows:
Choice -1: solve for x1
Choice -2: solve for x2
Choice -3: solve for x3
Choice -4: end program
- use the switch/case structure to implement the following equations and to display the results based on
the choices
x1 = ones (10)
x2= zeros(10)
x3=eye(5)
Also, figure out how to end the program if the choice is 4.
Submit the well documented Matlab code with results
5-
This question deals with if then else statements and while loops
Write a Matlab code for the following pseudo code.
a-
get user input of a number between 3 and 9 (make it user friendly)
bagain
if the number is less that 3, disply the message (Worng choice) and loop back to get user input
c-
if the number is between 3 and 5 (inclusive), then display the message “It is a nice Day”
d-
if the number is greater than 5 but less that 8, then displa the message “ I love Matlab”
eif the number is greater than or equal to 8 and less than or equal to 9, display the message “
Good”
f-
if the number is greater than 9, then display the message “ Worng choice” and loop back
Note, make sure you have a graceful way of exiting the program. So, if a user enters a specific data, the
program should terminate.
Submit the Matlab code and results for all cases.
6-
This question deals with logspace and semi log plots.
Assume you have the following filter equations:
1
𝐴𝑣 =
2
√1 + ( 𝑓 )
𝑓𝑐
𝑓
𝜃 = −𝑡𝑎𝑛−1 ( )
𝑓𝑐
𝐴𝑣(𝑑𝐵)= 20log⁡(𝐴𝑣)
Notice, in Matlab, log to base 10 is written as log10.
Given:
fc = 1KHz
Let the frequency vary from 10Hz to 100KHz.
Write a Matlab code that will plot on a semi log graph paper
- Av(dB) vs. f
- 𝜃 vs. f (𝜃 in degrees.)
Sumbit Matlab code and results.
7- None Matlab Code:
Answer the following questions regarding the results in question number 6.
- What is the low frequency gain in dB and in ratio forms?
- What is the phase angle at low frequencies?
- What is the gain in ration form and in decibels at f = fc ?
- What is the phase angle at f = fc ?
- does this response provide a phase lead or a phase lag ?
Download