===== ECEn 240 MATLAB Assignments ===== [[ EcEn 240 MATLAB Full Table of Content ]] ^ Chapter ^ Assignments ^ Course Topic ^ Matlab Topic ^ | Ch 0 | [[ecen_240_assignments#MT240.NR.0|MT240.NR.0]] | Intro to MATLAB | [[matlab_guide#Matlab Basic Operations| Matlab Basic Operations]], [[matlab_guide#Matrix Operations| Matrix Operations]], | | ::: | ::: | ::: | [[matlab_guide#Array Operations| Array Operations]], [[matlab_guide#Script Files| Script Files]] | | Ch 1 | [[ecen_240_assignments#MT240.NR.1|MT240.NR.1]] | Electrical Engineering Overview | | | ::: | [[ecen_240_assignments#MT240.NR.1.6.1|MT240.NR.1.6.1]] | Power and Energy | [[matlab_guide#Graph Function| Graph Function]] , [[matlab_guide#Axis Control| Axis Control]], | | ::: | ::: | ::: | [[matlab_guide#Annotation| Annotation]], [[matlab_guide#Figures| Figures]] | | Ch 2 | [[ecen_240_assignments#MT240.NR.2|MT240.NR.2]] | Circuit Elements | | | Ch 3 | [[ecen_240_assignments#MT240.NR.3|MT240.NR.3]] | Simple Resistive Circuit | | | ::: | [[ecen_240_assignments#MT240.NR.3.2.1|MT240.NR.3.2.1]] | Resistors in Parallel | [[matlab_guide#Function Files| Function Files]] | | ::: | [[ecen_240_assignments#MT240.NR.3.4.1|MT240.NR.3.4.1]] | Voltage and Current Division | [[matlab_guide#Function Files| Function Files]] | | Ch 4 | [[ecen_240_assignments#MT240.NR.4|MT240.NR.4]] | Techniques of Circuit Analysis | | | ::: | [[ecen_240_assignments#MT240.NR.4.3.1|MT240.NR.4.3.1]] | Node-Voltage w/ Dep. Sources | [[matlab_guide#Inverse Matrix| Inverse Matrix]] | | ::: | [[ecen_240_assignments#MT240.NR.4.12.1|MT240.NR.4.12.1]] | Maximum Power Transfer | Review | | Ch 5 | [[ecen_240_assignments#MT240.NR.5|MT240.NR.5]] | Operational Amplifier | | | ::: | [[ecen_240_assignments#MT240.NR.5.3.1|MT240.NR.5.3.1]] | The Inverting-Amplifier Circuit | [[matlab_guide#Matlab If-statement| If-statement]], [[matlab_guide#For-loop| For-loop]] | | ::: | [[ecen_240_assignments#MT240.NR.5.4.1|MT240.NR.5.4.1]] | The Summing-Amplifier Circuit | [[matlab_guide#Function Files| Functions continued]] | | Ch 6 | [[ecen_240_assignments#MT240.NR.6|MT240.NR.6]] | Inductance & Capacitance | | | ::: | [[ecen_240_assignments#MT240.NR.6.2.1|MT240.NR.6.2.1]] | The Capacitor | [[matlab_guide#For-loop| Perform an Integral using a for-loop]] | | Ch 7 | [[ecen_240_assignments#MT240.NR.7|MT240.NR.7]] | Response of 1st-Order RL & RC | | | ::: | [[ecen_240_assignments#MT240.NR.7.2.1|MT240.NR.7.2.1]] | Natural Response of RC Circuit | Review | | Ch 8 | [[ecen_240_assignments#MT240.NR.8|MT240.NR.8]] | Nat. & Step. Resp. of RLC Circuit | | | ::: | [[ecen_240_assignments#MT240.NR.8.2.1|MT240.NR.8.2.1]] | Forms Nat. Resp. of Parallel RLC | [[matlab_guide#Roots| Polynomial Roots]], [[matlab_guide#Real and Imaginary Command| Real and Imaginary Command]] | | Ch 9 | [[ecen_240_assignments#MT240.NR.9|MT240.NR.9]] | Sinusoidal Steady-State Analysis | | | ::: | [[ecen_240_assignments#MT240.NR.9.1.1|MT240.NR.9.1.1]] | The Sinusoidal Source | Review | | ::: | [[ecen_240_assignments#MT240.NR.9.9.1|MT240.NR.9.9.1]] | Mesh-Current Method | [[matlab_guide#Mesh| Mesh]], [[matlab_guide#Complex Numbers| Complex Numbers]] | | Ch 10 | [[ecen_240_assignments#MT240.NR.10|MT240.NR.10]] | Sinusoidal Steady-State Power Calc| | | ::: | [[ecen_240_assignments#MT240.NR.10.4.1|MT240.NR.10.4.1]] | Complex Power | [[matlab_guide#Annotation| Text]] | | ::: | [[ecen_240_assignments#MT240.NR.10.4.2|MT240.NR.10.4.2]] | Complex Power | Review | | Ch 12 | [[ecen_240_assignments#MT240.NR.12|MT240.NR.12]] | Intro to L. Transform | | | Ch 13 | [[ecen_240_assignments#MT240.NR.13|MT240.NR.13]] | L Transform in Circuit Analysis | | | Ch 14 | [[ecen_240_assignments#MT240.NR.14|MT240.NR.14]] | Intro to Freq. Selective Circuits | | | ::: | [[ecen_240_assignments#MT240.NR.14.4.1|MT240.NR.14.4.1]] | Band-Pass Filter | [[matlab_guide#Logarithmic| Logarithmic Plots]] | | Ch 15 | [[ecen_240_assignments#MT240.NR.15|MT240.NR.15]] | Active Filter Circuits | | | ::: | [[ecen_240_assignments#MT240.NR.15.1.1|MT240.NR.15.1.1]] | First-Order Low-Pass & High-Pass | Review | ===== Introduction to MATLAB ===== ===== MT240.NR.0 ===== Read and follow along with the document to get an introduction to MATLAB. \\ {{:240matlab:ch0:matlab_intro.pdf|}} \\ After completing the document, make sure that you feel comfortable with the following MATLAB topics: [[matlab_guide#Matlab Basic Operations| Matlab Basic Operations]] \\ [[matlab_guide#Matrix Operations| Matrix Operations]] \\ [[matlab_guide#Array Operations| Array Operations]] \\ [[matlab_guide#Script Files| Script Files]] \\ Even if you feel comfortable, click on the links above and become familiar with the MATLAB guide \\ provided on the wiki page. You may need to reference it later in the course. ===== Power & Energy ===== ==== MT240.NR.1.6.1 ==== == Document == {{:240matlab:ch1:mt240_nr_1_6_1_power.pdf|}} == Solution == {{:240matlab:solutions:ch1:mt240_nr_1_6_1_power.m|}} ===== Resistors In Parallel ===== ==== MT240.NR.3.2.1 ==== == Document == {{:240matlab:ch3:mt240_nr_3_2_1_parallelresistors.pdf|}} == Solution == {{:240matlab:solutions:ch3:mt240_nr_3_2_1_parallelresistors.m|}} ===== Voltage Division ===== ==== MT240.NR.3.4.1 ==== == Document == {{:240matlab:ch3:mt240_nr_3_4_1_voltage_division.pdf|}} == Solution == {{:240matlab:solutions:ch3:mt240_nr_3_4_1_voltage_division.m|}} ===== Node-Voltage w/ Dependent Sources ===== ==== MT240.NR.4.3.1 ==== == Document == {{:240matlab:ch4:mt240_nr_4_3_1_node_voltage_method.pdf|}} == Solution == {{:240matlab:solutions:ch4:mt240_nr_4_3_1_node_voltage_method.m|}} ===== Maximum Power Transfer ===== ==== MT240.NR.4.12.1 ==== == Document == {{:240matlab:ch4:mt240_nr_4_12_1_max_power_transfer.pdf|}} == Solution == {{:240matlab:solutions:ch4:mt240_nr_4_12_1_max_power_transfer.m|}} ===== Inverting Op-Amp ===== ==== MT240.NR.5.3.1 ==== == Documents == {{:240matlab:ch5:mt240_nr_5_3_1_inverting_op_amp.pdf|}} \\ {{:240matlab:ch5:mt240_nr_5_3_1_inverting_op_amp_function.pdf|}} == Solution == {{:240matlab:solutions:ch5:mt240_nr_5_3_1_inverting_op_amp.m|}} \\ {{:240matlab:solutions:ch5:mt240_nr_5_3_1_inverting_op_amp_function.m|}} ===== Summing Op-Amp ===== ==== MT240.NR.5.4.1 ==== == Documents == {{:240matlab:ch5:mt240_nr_5_4_1_sum_op_amp.pdf|}} \\ {{:240matlab:ch5:mt240_nr_5_4_1_sum_op_amp_function.pdf|}} == Solution == {{:240matlab:solutions:ch5:mt240_nr_5_4_1_sum_op_amp.m|}} \\ {{:240matlab:solutions:ch5:mt240_nr_5_4_1_sum_op_amp_function.m|}} == Another Application == (Not required, but for fun) Fun application Any wave or signal can be made up of tons of sinusoidal signals composed of different frequencies and amplitudes. The program below creates a square wave from n-number of input signals. Play around with the number of input signals to see the effect of adding more and more input signals. {{:240matlab:ch5:funapplication_sumopamp.m|}} To run this program you will need to edit the code and use your summing op amp function. ===== Capacitor ===== ==== MT240.NR.6.2.1 ==== == Document == {{:240matlab:ch6:mt240_nr_6_3_1_capacitor.pdf|}} == Solution == {{:240matlab:solutions:ch6:mt240_nr_6_3_1_capacitor.m|}} ===== Natural Response of RC Circuit ===== === MT240.NR.7.2.1 === == Document == {{:240matlab:ch7:mt240_nr_7_2_1_nat_tesp_rc_circuit.pdf|}} == Solution == {{:240matlab:solutions:ch7:mt240_nr_7_2_1_nat_tesp_rc_circuit.m|}} === RLC Circuit === ==== MT240.NR.8.2.1 ==== == Document == {{:240matlab:ch8:mt240_nr_8_2_1_rlc_circuit.pdf|}} == Solution == {{:240matlab:solutions:ch8:mt240_nr_8_2_1_rlc_circuit.m|}} ===== Sinusoidal Source ===== ==== MT240.NR.9.1.1 ==== == Document == {{:240matlab:ch9:mt240_nr_9_1_1_sinusoidal_source.pdf|}} == Solution == {{:240matlab:solutions:ch9:mt240_nr_9_1_1_sinusoidal_source.m|}} ===== Z-Circuit Analysis with Mesh Current Method ===== ==== MT240.NR.9.9.1 ==== == Document == {{:240matlab:ch9:mt240_9_9_1_mesh_current_method.pdf|}} == Solution == {{:240matlab:solutions:ch9:mt240_9_9_1_mesh_current_method.m|}} ===== Complex Power ===== ==== MT240.NR.10.4.1 ==== MT240_10_4_1 Complex Power Objective: Gain a visual understanding of complex power Functions to learn: refline (this could be useful) to plot avg P and reactive P. text (this could be useful) to label your average and reactive power. Exercise: You have seven black boxes(representing unknown circuits), each with terminals coming out of them. You are curious to identify which circuits are more inductive, capacitive, or neither. You begin by measuring the voltage and current across each terminal and measure the voltage phase shift in reference to the current phase shift by setting the current phase shift to zero. From your measurements you gather the following parameters: V = 5*cos(w*t + thetaV), with 'w' being the frequency in rads/s (w = 100*pi), 't' being the duration of time (t = 0:T/100:2*T - T/100), 'T' being the period of the signal (T = 2*pi/w), thetaV being the voltage phase shift, (thetaV = [-pi/2, -pi/4, -pi/6, 0, pi/6, pi/4, pi/2]. thetaV(1) represents the first black box, thetaV(2) the second and so on), and a current I = 1.25*cos(w*t). To gain a visual understanding you decide to calculate and plot the average power, reactive power, and instantaneous power for the different voltage phase shifts using the parameters given. a) Calculate the voltages as a function of time for all values of thetaV. b) Calculate the Vrms and Irms using a for-loop to approximate an integral Vrms = sqrt((1/T)*integral(V(t), from 0 to T)dt) bounds of integration are from 0 to T. Verify your calculation using the equation Vrms = Vm/sqrt(2). c) Calculate average, reactive, and instantaneous power for every thetaV. d) Plot voltage, current, average, reactive, and instantaneous power obtained from part c. It might be best to create a single plot for each theta since you are plotting a lot of information on each graph. Using a legend, titles, and labels will help you sort through the information. e) Why are all of the calculated Vrms values the same even though the phase shift was different? f) When the reactant power is zero what is the relationship between the phases of voltage and current? What does this tell you about the circuit. g) When the reactant power is below zero does the voltage lead or lag the current. Is the circuit more inductive or capacitive? h) When the current and voltage are in phase, why is the instantaneous power never below 0? When it is below zero what is happening to the power? == Image == {{:240circuits:power.png?200|}} == Template == {{:240matlab:ch10:mt240_10_4_1_t_complexpowertemplate.m|}} == Solution Image == {{:240matlab:ch10:mt240_10_4_1_si1_complexpowersolutionimage1.jpg?400|}} {{:240matlab:ch10:mt240_10_4_1_si2_complexpowersolutionimage2.jpg?400|}} == Solution == {{:240matlab:solutions:ch10:mt240_10_4_1_complexpower.m|}} ===== Complex Power ===== ==== MT240.NR.10.4.2 ==== {{:240matlab:ch10:mt240_10_4_2_complex_power.pdf|}} == Solution == {{:240matlab:solutions:ch10:mt240_10_4_2_complex_power.m|}} ===== Passive Filters ===== ==== MT240.NR.14.4.1 ==== == Document == {{:240matlab:ch14:mt240_14_4_1_crossover_network.pdf|}} == Solution == {{:240matlab:solutions:ch14:mt240_14_4_1_crossover_network.m|}} ===== Active Filter ===== ==== MT240.NR.15.1.1 ==== MT240_15_1_1 Active Filter Objective: Design a an active, low-pass filter using an op-amp Commands: none Background: While designing your crossover network you realized that the bass speaker's (low pass) amplifier has broken. You then decide to build the low pass filter and amplifier as one unit using an op-amp. You decide to get fancy and use a variable capacitor so that you can change the corner frequency. Exercise: You decide to have design according to the topology shown in the image below. a) Design your circuit to have a max gain of 10. b) Your variable capacitor can assume values within the range: C = 1e-8:1e-7:1e-6; c) For every capacitor value calculate the transfer function |H(jw)| as a a function of frequency using w(rads/sec) = 0:5*2*pi:3e5*2*pi; d) Create a bode plot of the results obtained in part c. Plot them all on the same graph. d) What value should the capacitor be if you want a corner frequency of about 140 Hz? e) What affect does the size of the capacitor have on the bandwidth? == Image == {{:240circuits:hw14.png?400|}} == Template == {{:240matlab:ch15:mt240_15_1_1_t_activefiltertemplate.m|}} == Solution Image == {{:240matlab:ch15:mt240_15_1_1_si_activefiltersolutionimage.jpg?400|}} == Solution == {{:240matlab:solutions:ch15:mt240_15_1_1_activefilter.m|}}