EEE116 Experimental, Computer Skills and

EEE116 Experimental, Computer Skills and
Sustainability: MATLAB Group Assignment
Due on Monday, 13th May, 2019, 18:00
2 / 16
Assignment Regulations
This is a group assignment. Each group MUST submit one soft copy of the group
report via the ICE before the due date.
A coversheet can be created in your own way, but the following information MUST
be included: your group number, student ID number, full name and email address
of each group member.
All the formula, derivations, completed MATLAB scripts and functions with
original highlighted text format in MATLAB editor, computational results in the
command window, and plotted figures, should be part of the answers.
There is no hard requirement on how the report must be organized. You can
organize your report question by question (i.e. give one section for each question).
Then, for each section, you can organize it in your own way. However, the contents
and information required by each individual question MUST be provided.
You may refer to textbooks and lecture notes to discover approaches to problems,
however, the assignment should be your own group work.
Where you do make use of other reference, please cite them in your work. Students
are reminded to refer and adhere to plagiarism policy and regulations set by XJTLU.
References, in IEEE style can be attached as an appendix.
A contribution form MUST be provided which can be given as the final page of
your report. You can follow the example contribution form provided in the final
page of this document.
Assignments may be accepted up to 5 working days after the deadline has passed;
a late penalty of 5% will be applied for each working day late without an extension
being granted. Submissions over 5 working days late will not be marked. Emailed
submissions will NOT be accepted without exceptional circumstances.
3 / 16
MATLAB Group Assignment for EEE116
Part I: developing basic programming skills by solving
simple engineering problems
Question I-A, Numerical method for solution of ordinary differential equations.
(25 Marks)
The classical method of solving ordinary differential equations (ODE) is the 4th order
Rugge-Kutta method. The algorithm is given below:
Assume we have a 1st order ODE:
(I-A.1)
For the given time period, we need to find out the time variation of y, given
the initial condition. This kind of problem is referred to as initial value
problems.
For solution, let us have divide the time period into N intervals (i.e. N+1 time instants),
then the value of y at (n+1)th time instant is given by the following relations with n
from 0 to N with h as the time interval size:
(I-A.3)
Question (a) (15 Marks): Now, solve an RC circuit problem: the equation for the
voltage y across the capacitor is
(I-A.4)
where is the applied voltage to the circuit. Suppose that RC = 0.2 s and that the
capacitor voltage, y, is initially 2 V (i.e.). Suppose also that the applied
4 / 16
voltage is 
sin V. Plot the voltage y(t) for 0 ≤ 5 s.
Requirements:
(1) (7 Marks) Write a function file to give a general ODE solver using Runge-Kutta
method, e.g.
function [ t,y ] = marunge4s( dyfun,tspan,y0,h )

EEE116作业代做、MATLAB语言作业代写、MATLAB编程设计作业调试、代写Computer Skills作业
where “marunge4s” is the function name; “dyfun” is the name of the ODE to be solved
which is defined by using a function; “tspan” is the time period to be simulated; y0 is
the initial condition of the solved-for variable, “h” is the time interval size.
(2) (5 Marks) Do the above question. i.e. solve Equation I-A.1, by calling the function
created. Then, plot the voltage y(t) for 0 ≤ 5 s.
Hints: For this question, you need to create your own function file using Runge-Kutta
method (This is done for Question (1)), which is similar to ode45 (a MATLAB standard
function of solving ODEs), to solve the ODE defined by another function (refer to hints
of Question (3) for how to do this). Then, the calling pattern of your function (to solve
ODEs) should be, e.g.
[t,y1]=marunge4s('RC_circuit',[0 0.5],2,0.001);
where “RC_circuit” is the name of the ODE you have defined using a function
file; 0.001 is h, the time interval size. You need to use the function ‘feval’ in your
function “marunge4s” if the pattern is shown above. If you do not wish to use ‘feval’,
then the calling pattern should be:
[t,y1]=marunge4s(@RC_circuit,[0 0.5],2,0.001);
(3) (3 Marks) Check your solution by using a MATLAB standard function for solving
ODEs, i.e. ode45: you need to plot results of voltage y(t) for 0 ≤ ?? ≤ 5 s, obtained by
using both your user defined function and ode 45, then, compare the results and
comment on the features (e.g. whether they are the same or not?)
Hints: An example of using ode45: we need to first define the ODE to be solved which
can be done by using a function, e.g.
The function file defining the ODE to be solved:
function [ ydot ] = RC_circuit( t,y )
%define the ODE by using a function to be called by
%MATLAB function ode45 or
%your own function solver using Runge-Kutta method
Vsource=100*sin(2*pi*50*t);
ydot=-5*y+5*Vsource;
end
5 / 16
Then, use ode45 function to solve the equation you just defined using a function, as
shown below:
The main programme written in a script file:
clear all
close all
clc
%
%'RC_circuit' is the ODE name defined by a function
%[0 0.5] is the time period for the simulation
%2 is the initial conditions, v_c(t=0)=2 V
[t,y]=ode45('RC_circuit',[0 0.5],2);
plot(t,y(:,1))
xlabel('time (s)')
ylabel('capacitor voltage (V)')
Question (b) (10 Marks): Now, we consider the RLC circuit with R, L and C connected
in series, in which the capacitor voltage vc is governed by a 2nd order ODE:
(I-A.5)
where v(t) is the applied power supply voltage. Suppose we have R = 100 ohms, L =
0.5 Henries and C = 2e-6 Farads. Solve the equations with the following conditions:
(1) (5 Marks) Model input: Initial conditions:
0, then plot the results, i.e. the voltage
(2) (5 Marks) Model input:, with f = 50 Hz; Initial
(0) = 0 , then plot the results for both two
initial conditions, i.e. the voltage 
Hints: The 2nd order ODE can be written into a set of 2 1st oder ODEs (see below), and
then the question becomes to solve 2 1st order ODEs using Kugge-Kutta method.
Assume two vector spaces, X and Y, with the size of 2 × 1 each, then we let:
] . For using MATLAB supplied function,
ode45, an example is given below:
The function file defining the ODE to be solved:
function [ xdot ] = CircuitRLC( t,x )
%define the ODE by using a function to be called by
%MATLAB function ode45 or
%your own function solver using Runge-Kutta method
Vsource=100*sin(2*pi*50*t);
C=2e-6;
R=100;
L=0.5;
xdot=zeros(2,1);
xdot(1)=x(2);
xdot(2)=Vsource/(L*C)-(R/L)*x(2)-(1/(L*C))*x(1);
end
The main programme written in a script file:
clear all
close all
clc
%
7 / 16
%[0 0.5] is the time period for the simulation
%[100 0] is the initial conditions, v_c(t=0)=100 V,
dv_c/dt(t=0)=0
[t,x]=ode45('CircuitRLC',[0 0.3],[100 0]);
plot(t,x(:,1))
xlabel('time (s)')
ylabel('capacitor voltage (V)')
The user defined function file required in Question (a), “marunge4”, should also be able
to solve this kind of 2nd order ODEs, not just one 1st order ODE. Think about how to do
this.
Requirements: for Question I-A, in your report, the following information needs to
be included:
a) Circuit diagram, the relevant equation derivations and all the known conditions
stated in the question;
b) Flow chart of the programme design;
c) Coding with detailed notes on the key steps;
d) Results.
8 / 16
Question I-B, Kinematics analysis for a slider-crank linkage.
(25 Marks)
Consider a slider-crank linkage which is the fundamental mechanism used in car
engines, a schematic diagram is shown in Figure I-B.1. Knowing the geometrical
parameters of the mechanism and the rotational speed of the driver linkage, try to do
the kinematics analysis for the mechanism to calculate the displacements, velocity and
acceleration.
Figure I-B.1. Schematic of a slider-crank linkage mechanism.
The general procedure of kinematic analysis is given below:
(a) Displacement analysis
The position vector equation is
(I-B.1)
Write it in the form of complex numbers, it becomes
Separate the real and imaginary parts, we have
(I-B.3)
Then we have
(I-B.4)
9 / 16
(b) Velocity analysis
Find the first derivative of equation (B.2), we have
(I-B.5)
Separate the real and imaginary parts, we have
(I-B.6)
Write the above equation in the matrix form
[
(I-B.7)
(c) Acceleration analysis
Get the second derivative for equation (B.2) then separate real and imaginary parts
(equivalent to directly differentiate equation (B.6)), we have
(I-B.9)
For the mechanism of Figure I-B.1, suppose L1 = 100 mm, L2 = 300 mm,
10, the dimensions of the slider block is [x,y]=[80 mm,20 mm], try to do the
following:
(1) (10 Marks) Calculate the displacement, velocity and acceleration for Slider C (sc,
vc, ac) and the angular counterparts for Linkage 2 (??2, ??2, ??2). You can create a function
file (e.g. [outputs] = slider_crank(inputs)) for this by using Equations (I-B.4), (I-B,7)
and (I-B.9).
(2) (5 Marks) Plot the results as a function of the driver rotational angle (??1) which
ranges from 0 to 720 deg. Call the function created in Question (1) to get the results
then plot them out.
(3) (10 Marks) Create the movie showing the movement of this mechanism, when the
driver rotational angle (??1) varies from 1 to 360 deg. You may need to use the MATLAB
functions “getframe” and “movie()”.
10 / 16
Requirements: for Question I-B, in your report, the following information needs to
be included:
a) The schematic diagram of the mechanism, the relevant equation derivations and all
the known conditions stated in the question;
b) Flow chart of the programme design;
c) Coding with detailed notes on the key steps;
d) Results.
11 / 16
Problem I-C, Solve nonlinear equations using Newton-Raphson method.
(10 Marks)
Write a programme to solve the circuit with a diode as shown in Figure I-C.1.
Figure I-C.1. A simple diode circuit, where VPS = 5 V and R = 2 kohms.
The current-voltage characteristic of the diode is
(I-C.2)
Equation (I-C.2) is nonlinear which is difficult to be solved analytically. Therefore, try
to write a program using Newton-Raphson algorithm to solve it, then print the result of
the solved value VD in the command window. Details of the Newton-Raphson method
and the example has ben given in MATLAB lecture notes “Matlab Tutorial 2-2018-19”,
Slides 50-55.
Requirements: for Question I-C, in your report, the following information needs to
be included:
a) Circuit diagram, the relevant equation derivations and all the known conditions
stated in the question;
b) Flow chart of the programme design;
c) Coding with detailed notes on the key steps;
d) Results.
12 / 16
Part II: Use Simulink to solve simple engineering problems
Question II-A, The motion of a two-mass suspension model.
(20 Marks)
Consider the two-mass suspension model shown in Figure II-A.1. The equations of
motion are:
(II-A.1)
(1) (15 Marks) Develop a Simulink model of this system. In your report, you need to
give information on:
a) Answer a question: whether to use a state-variable representation or a transferfunction
representation of the model, and why?
(3 Marks)
b) How is the Simulink model derived? In your report, you need to present (i) all
the relevant equation derivations based on which you get the Simulink model,
and (ii) the complete Simulink model.
(6 Marks)
c) For each block you have in your Simulink model, give details on all the settings,
and the reasons for your settings.
(6 Marks)
(2) (5 Marks) Use the Simulink model to plot the response for the following input, f(t).
The initial conditions are zero,
(II-A.2)
Figure II-A.1. Two-mass suspension model.
Hints:
a) The input to your model, can be implemented by using “Signal Builder” block.
b) To complete this question, you can also read and understand contents in my lecture
notes: Matlab Tutorial 3-2018-19, specially from pp. 21.
13 / 16
Question II-B, The motion of a single-mass suspension model of the vehicle
suspension system.
(20 Marks)
Consider the single-mass suspension model shown in Figure II-B.1, which is typical
representation of the vehicle suspension system. The spring and damper forces ???? and have the nonlinear models. When the vehicle strikes a bump, the road surface profile
can be represented by the trapezoidal function y(t) shown in Figure II-B.2. Now, the
system model (derived from Newton’s law) becomes:
is the is the nonlinear spring function shown in Figure
II-B.3, and is the nonlinear damper function given by:
(1) (15 Marks) Develop a Simulink model of this system. In you report, you need to
state clearly:
a) Answer a question: whether to use a state-variable representation, or a transferfunction
representation, or nonlinear treatment, to create the corresponding
model in Simulink, and why?
(3 Marks)
b) How is the Simulink model derived? In your report, you need to present (i) all
the relevant equation derivations based on which you get the Simulink model,
and (ii) the complete Simulink model.
(6 Marks)
c) For each block you have in your Simulink model, give details on all the settings,
and the reasons for your settings.
(6 Marks)
(2) (5 Marks) Use the Simulink model to plot the response of this system, i.e. x and
(y-x) versus t. The initial conditions are zero, i.e. ?? = 0 and ??? = 0.
a) Plot the responses in Simulink using Scope. In your report, present the screen
shots.
(2 Marks)
b) Export the data into MATLAB workspace which enable you to use “plot”
command to plot the responses. In your report, state (i) how do you export
Simulink results to workspace, and, (ii) present the plots you have done using
“plot” command, and show clearly the axis labels (i.e. for x and y axis, what
quantities do you plot and units) and legends if applicable.
(3 Marks)
14 / 16
Hints:
a) The road surface profile, y(t) as shown in Figure II-B.2, which is the input to your
model, can be implemented by using “Signal Builder” block.
b) The spring function, as shown in Figure II-B.3, can be implemented by using
“Look-Up Table” block.
c) The damper function, given by Equation (II-B.2), can be implemented by using
“MATLAB function” block.
d) To complete this question, you can also read and understand contents in:
My lecture notes: Matlab Tutorial 3-2018-19, specially from pp. 47.
Textbook: Palm William, Introduction to MATLAB for Engineers (3
rd Edn.),
McGraw Hill Professional, Section 10.9, Chapter 10.
Figure II-B.1. Single-mass model of a vehicle suspension.
Figure II-B.2. Road surface profile.
15 / 16
Figure II-B.3. Nonlinear spring function.
16 / 16
Contribution Form – MATLAB Group Assignment
Group____:
Name and
Student ID
number
Overall
contribution
(%)
Problem analysis
and equation
derivations, etc.
(%)
MATLAB
programming
(%)
Report writing
(%)
Comments
A
12345678
37 40 60 10 For example: Lead in the
completion of the
assignment and contribute
the most in MATLAB
programming
B
12345678
30 20 15 55 For example: Work closely
with other group members,
contributes particularly in
Component 3.
C
12345678
28 35 20 30 For example: Work closely
with other group members,
contributes almost evenly
in Component 1 and 3.
D
12345678
5 5 5 5 For example: He/she
contributes very little.
Total 100% 100% 100% 100%
The parts highlighted in red are which you need to fill in.
The contribution form will be used to monitor the workload distribution within the
group, and will also provide a basis for differentiate your marks (if there are
substantial workload differences between team members).

因为专业,所以值得信赖。如有需要,请加QQ99515681 或邮箱:[email protected] 

微信:codinghelp

猜你喜欢

转载自www.cnblogs.com/ksypython/p/10800645.html