ELEC171-ELEC172 MATLAB Assignment
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
Department of Electrical Engineering and Electronics ELEC171-ELEC172 MATLAB Assignment |
INSTRUCTIONS AND GUIDANCE – READ THIS SECTION CAREFULLY • You must submit a single Word document for the entire assignment. • For each question, you should include the code and the output, as outlined below: • Your MATLAB code § The code should be directly copied and pasted as TEXT into the document. § Your cut-pasted code should retain the same colour-coding that appears in MATLAB • Output from the program (where required) § Figures or screenshots should be pasted into the document as PNG or JPG files. • The marks for each question will be based on the two criteria below o Correctness: program code, program output, graphs (70%) o Coding style: appropriate names for variables, appropriate comments in the code, appropriate line spacing for readability (30%) |
Assignment Specifications
Coursework name |
MATLAB Assignment |
Component weight |
ELEC171: 12%, ELEC172: 25% |
Semester |
1 |
HE Level |
4 |
Work |
Individual |
Suggested study time |
5 hours |
Assessment method |
Assignment with multiple programming tasks |
Submission format |
Online via Canvas |
Submission deadline |
11:59 pm on Friday 17th December, 2021 |
Late submission |
Standard university penalty applies |
Resit opportunity |
August resit period |
Marking policy |
Marked and moderated independently |
Anonymous marking |
Yes |
Feedback |
via Canvas |
Subject of relevance |
MATLAB programming |
Learning outcomes |
(LO9) To solve mathematically oriented problems by writing simple programmes in MATLAB. |
Assignment Questions
Q1) (30 marks)
Write a MATLAB program to evaluate and plot the two following expressions. Your assignment document should contain the program code and a screenshot of the output that is created when the program is run.
The two expressions are:
• y = e-x + 2x3 − 6x2 + 1
• dy = -e-x + 6x2 − 12x
Your program should carry out the following tasks.
a) Evaluate y and dy for values of x between - 10.0 and 10.0. You should use a sufficient number of x values to create smooth curves when you create the plots required for part (b).
b) Plot y and dy in a single figure containing two graphs. The two graphs should be arranged vertically so that the graph displaying y is in the upper part of the figure, and the graph containing dy is in the lower part of the figure. Each graph should be correctly labelled and have a title. The data for both graphs should be plotted using blue lines.
Q2) (35 marks)
Create two MATLAB files to carry out the following tasks. Your assignment document should contain the program codes and a screenshot of the output that is created when the program is
run.
The task for this question is to write a function that accepts temperature T in degrees Celsius and calculates the corresponding value in degrees Fahrenheit. The relationship between the two values is given by:
TF = 9/5 * TF + 32
where TF is the temperature in degrees Fahrenheit and TC is the temperature in degrees
Celsius.
a) First, open a file and write the code for the function to convert TC to TF.
b) In a separate file, write a program that carries out the following tasks
• Uses the function from part (a) to calculate TF for a set of temperatures in the range of – 100 oC to +100 oC, with increments of 1 oC.
• Plots an x-y graph with the x-axis showing TC and the y axis showing TF. Display a graph title and labels for both axes. Turn on the grid. Use a black line to plot the data.
Q3) (35 marks)
Write a MATLAB program to carry out the following tasks. Your assignment document should contain the program code and a screenshot of the input and output that is created when the program is run.
Your task is to write a program that asks a user for information about monthly costs for different living expenses, calculates the total monthly spend and displays the information for the user.
Your program should do the following:
• Display text that explains the purpose of the program to a user
• Prompt the user to input their estimated monthly expenses for the following items
o Food and household shopping (supermarkets, takeout food etc)
o Entertainment spending (cafes, cinema, hobbies etc)
o Travel (monthly train, bus, taxi etc)
o Rent
o Utilities charges (electricity, gas, water, phone, etc)
o Other expenses (clothes, savings for vacation travel, etc)
• Calculate the total monthly costs for the user
• Display the information to the user in a user-friendly, easy-to-read format
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. Your assignment document should contain code presented in this way.
% 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
2023-01-02