the assignment has 4 questions. I just need questions 2 and 3 to be done. Also I do not want it professional and no one has the same work as mine.
Microsoft Word - Matlab Resit Assignment 2017-18 (draft).docx Department of Electrical and Electronic Engineering ELEC171 - ELEC172 MATLAB Resit Assignment Deadline: Friday 10/08/2018 at 11:59 PM ----------------------------------------------------------------------------------------------------------------------------------- INSTRUCTIONS AND GUIDANCE – READ THIS PAGE CAREFULLY Instructions for completing and submitting this assignment You must submit a single Word document for the entire assignment. For each questions, you need to include several parts: a) Your MATLAB code The code should be cut-pasted at TEXT into the document. Use Courier New font for the source code, with font size 11pt. Your cut-pasted code should retain the same colour-coding that appears in MATLAB b) Output from the program (where required) Graphs should be pasted into the document as PNG or JPG files. Marking scheme: The marks for each question will be based on the three criteria below Completeness: all sections completed Correctness: program code, program output, graphs, answers to questions Coding style: appropriate names for variables, appropriate comments in the code, appropriate line spacing for readability ELEC171/172 MATLAB 1 Q1) Create a file called Question1.m. Your assignment document should contain the code from this file and a screenshot of the command window after you have run the file. Your code should only display the output from part f) in the command window. (20 marks) a) Create the matrix A in your file: ? = 3 0 2 2 1 8 6 1 9 0 2 6 b) Using a Matlab operator, create a vector p consisting of the elements in the second column of A. c) Using a Matlab operator, create a vector q consisting of the elements in the third row of A. d) Using a Matlab operator, create variables p_len and q_len that contain the lengths of p and q respectively. e) Write code to create variables A_size that contain the size of A. f) Write code that displays the variables p, A, q_len, and A_size in the command window Q2) Create a file called “Question2.m”, and write code to carry out the following tasks. (20 marks) a) Evaluate the expression ? = ? − 6? − 3 for all values of x between 0.1 and 5.0, in steps of 0.1, using a for loop in the program b) Plot the output from your calculations in a single figure. Your graph should be correctly labelled and have a title. Q3) Create a file called “Question3.m”, and write code to carry out the following tasks. (30 marks) ?(?) = ? 0 <>< 2="" −="" 2?="" +="" 4="" 2=""><>< 4="" 3?="" 4=""><>< 5="" a)="" write="" code="" for="" the="" function="" and="" save="" it="" in="" a="" file="" called="" funcxy.m.="" b)="" write="" a="" short="" program="" that="" evaluates="" the="" function="" for="" 0="">< x="">< 5 elec171/172 matlab 2 q4) create a file called “question4.m”, and write code to carry out the following tasks. (30 marks) write a program which plots the amplitude and phase of function f(t) for 0 ≤ t ≤ 10, for the complex function ?(?) = (1 + 3?)? − 3?? + 4 plot both the amplitude and the phase on the same figure, with the axes positioned one above the other. add plot titles for each plot. add labels for the x and y axes. include grids in your plots. ----------------------------------------------------------------------------------------------------------------------------------- code example the text below is an example of a program cut-pasted from matlab to word, with courier new 11 pt font, and with the colour-coding retained from the original matlab file. % example code written to show the way programs should be included % in the text of the matlab assignment. % the program calculates current and power for a circuit containing a voltage source and a resistor. the values of voltage and resistance are contained in the arrays data_voltage and data_resistance. % data obtained from the circuit data_voltage = [0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0]; data_resistance = [2.5, 5.5, 8.2, 11.1, 14.4, 17.9, 21.9, 25.2, 30.0, 34.7]; % calculate current based on ohm’s law i = v/r current = data_voltage / data_resistance; % calculate power based p = v^2/r power = (data_voltage .^ 2) / data_resistance; % end of file – question1.m 5="" elec171/172="" matlab="" 2="" q4)="" create="" a="" file="" called="" “question4.m”,="" and="" write="" code="" to="" carry="" out="" the="" following="" tasks.="" (30="" marks)="" write="" a="" program="" which="" plots="" the="" amplitude="" and="" phase="" of="" function="" f(t)="" for="" 0="" ≤="" t="" ≤="" 10,="" for="" the="" complex="" function="" (?)="(1" +="" 3?)?="" −="" 3??="" +="" 4="" plot="" both="" the="" amplitude="" and="" the="" phase="" on="" the="" same="" figure,="" with="" the="" axes="" positioned="" one="" above="" the="" other.="" add="" plot="" titles="" for="" each="" plot.="" add="" labels="" for="" the="" x="" and="" y="" axes.="" include="" grids="" in="" your="" plots.="" -----------------------------------------------------------------------------------------------------------------------------------="" code="" example="" the="" text="" below="" is="" an="" example="" of="" a="" program="" cut-pasted="" from="" matlab="" to="" word,="" with="" courier="" new="" 11="" pt="" font,="" and="" with="" the="" colour-coding="" retained="" from="" the="" original="" matlab="" file.="" %="" example="" code="" written="" to="" show="" the="" way="" programs="" should="" be="" included="" %="" in="" the="" text="" of="" the="" matlab="" assignment.="" %="" the="" program="" calculates="" current="" and="" power="" for="" a="" circuit="" containing="" a="" voltage="" source="" and="" a="" resistor.="" the="" values="" of="" voltage="" and="" resistance="" are="" contained="" in="" the="" arrays="" data_voltage="" and="" data_resistance.="" %="" data="" obtained="" from="" the="" circuit="" data_voltage="[0.5," 1.0,="" 1.5,="" 2.0,="" 2.5,="" 3.0,="" 3.5,="" 4.0,="" 4.5,="" 5.0];="" data_resistance="[2.5," 5.5,="" 8.2,="" 11.1,="" 14.4,="" 17.9,="" 21.9,="" 25.2,="" 30.0,="" 34.7];="" %="" calculate="" current="" based="" on="" ohm’s="" law="" i="V/R" current="data_voltage" data_resistance;="" %="" calculate="" power="" based="" p="V^2/R" power="(data_voltage" .^="" 2)="" data_resistance;="" %="" end="" of="" file="" –=""> 5 elec171/172 matlab 2 q4) create a file called “question4.m”, and write code to carry out the following tasks. (30 marks) write a program which plots the amplitude and phase of function f(t) for 0 ≤ t ≤ 10, for the complex function ?(?) = (1 + 3?)? − 3?? + 4 plot both the amplitude and the phase on the same figure, with the axes positioned one above the other. add plot titles for each plot. add labels for the x and y axes. include grids in your plots. ----------------------------------------------------------------------------------------------------------------------------------- code example the text below is an example of a program cut-pasted from matlab to word, with courier new 11 pt font, and with the colour-coding retained from the original matlab file. % example code written to show the way programs should be included % in the text of the matlab assignment. % the program calculates current and power for a circuit containing a voltage source and a resistor. the values of voltage and resistance are contained in the arrays data_voltage and data_resistance. % data obtained from the circuit data_voltage = [0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0]; data_resistance = [2.5, 5.5, 8.2, 11.1, 14.4, 17.9, 21.9, 25.2, 30.0, 34.7]; % calculate current based on ohm’s law i = v/r current = data_voltage / data_resistance; % calculate power based p = v^2/r power = (data_voltage .^ 2) / data_resistance; % end of file – question1.m>