EEE116 Experimental, Computer Skills andSustainability: MATLAB Group AssignmentDue on Monday, 13th May, 2019, 18:002 / 16Assignment Regulations This is a group assignment. Each group MUST submit one soft copy of the groupreport via the ICE before the due date. A coversheet can be created in your own way, but the following information MUSTbe included: your group number, student ID number, full name and email addressof each group member. All the formula, derivations, completed MATLAB scripts and functions withoriginal highlighted text format in MATLAB editor, computational results in thecommand window, and plotted figures, should be part of the answers. There is no hard requirement on how the report must be organized. You canorganize 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 contentsand 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. Studentsare 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 ofyour report. You can follow the example contribution form provided in the finalpage 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 extensionbeing granted. Submissions over 5 working days late will not be marked. Emailedsubmissions will NOT be accepted without exceptional circumstances.3 / 16MATLAB Group Assignment for EEE116Part I: developing basic programming skills by solvingsimple engineering problemsQuestion I-A, Numerical method for solution of ordinary differential equations.(25 Marks)The classical method of solving ordinary differential equations (ODE) is the 4th orderRugge-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, giventhe initial condition. This kind of problem is referred to as initial valueproblems.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 nfrom 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 thevoltage y across the capacitor is�(I-A.4)where is the applied voltage to the circuit. Suppose that RC = 0.2 s and that thecapacitor voltage, y, is initially 2 V (i.e.). Suppose also that the applied4 / 16voltage 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-Kuttamethod, e.g.function [ t,y ] = marunge4s( dyfun,tspan,y0,h )where “marunge4s” is the function name; “dyfun” is the name of the ODE to be solvedwhich is defined by using a function; “tspan” is the time period to be simulated; y0 isthe 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 functioncreated. Then, plot the voltage y(t) for 0 ≤ 5 s.Hints: For this question, you need to create your own function file using Runge-Kuttamethod (This is done for Question (1)), which is similar to ode45 (a MATLAB standardfunction of solving ODEs), to solve the ODE defined by another function (refer to hintsof Question (3) for how to do this). Then, the calling pattern of your function (to solveODEs) 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 functionfile; 0.001 is h, the time interval size. You need to use the function ‘feval’ in yourfunction “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 solvingODEs, i.e. ode45: you need to plot results of voltage y(t) for 0 ≤ ?? ≤ 5 s, obtained byusing both your user defined function and ode 45, then, compare the results andcomment 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 whichcan 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 methodVsource=100*sin(2*pi*50*t);ydot=-5*y+5*Vsource;end5 / 16Then, use ode45 function to solve the equation you just defined using a function, asshown below:The main programme written in a script file:clear allclose allclc%%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 connectedin 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 twoinitial conditions, i.e. the voltage �Hints: The 2nd order ODE can be written into a set of 2 1st oder ODEs (see below), andthen 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 methodVsource=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);endThe main programme written in a script file:clear allclose allclc%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 ableto solve this kind of 2nd order ODEs, not just one 1st order ODE. Think about how to dothis.Requirements: for Question I-A, in your report, the following information needs tobe included:a) Circuit diagram, the relevant equation derivations and all the known conditionsstated in the question;b) Flow chart of the programme design;c) Coding with detailed notes on the key steps;d) Results.8 / 16Question I-B, Kinematics analysis for a slider-crank linkage.(25 Marks)Consider a slider-crank linkage which is the fundamental mechanism used in carengines, a schematic diagram is shown in Figure I-B.1. Knowing the geometricalparameters of the mechanism and the rotational speed of the driver linkage, try to dothe kinematics analysis for the mechanism to calculaEEE116作业代做、MATLAB语言作业代写、MATLAB编程设计作业调试、代写Computer Skills作业 帮te the displacements, velocity andacceleration.Figure I-B.1. Schematic of a slider-crank linkage mechanism.The general procedure of kinematic analysis is given below:(a) Displacement analysisThe 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 analysisFind 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 analysisGet 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 thefollowing:(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 functionfile (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) whichranges from 0 to 720 deg. Call the function created in Question (1) to get the resultsthen plot them out.(3) (10 Marks) Create the movie showing the movement of this mechanism, when thedriver rotational angle (??1) varies from 1 to 360 deg. You may need to use the MATLABfunctions “getframe” and “movie()”.10 / 16Requirements: for Question I-B, in your report, the following information needs tobe included:a) The schematic diagram of the mechanism, the relevant equation derivations and allthe 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 / 16Problem 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, tryto write a program using Newton-Raphson algorithm to solve it, then print the result ofthe solved value VD in the command window. Details of the Newton-Raphson methodand 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 tobe included:a) Circuit diagram, the relevant equation derivations and all the known conditionsstated in the question;b) Flow chart of the programme design;c) Coding with detailed notes on the key steps;d) Results.12 / 16Part II: Use Simulink to solve simple engineering problemsQuestion 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 ofmotion are:�(II-A.1)(1) (15 Marks) Develop a Simulink model of this system. In your report, you need togive information on:a) Answer a question: whether to use a state-variable representation or a transferfunctionrepresentation of the model, and why?(3 Marks)b) How is the Simulink model derived? In your report, you need to present (i) allthe 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 lecturenotes: Matlab Tutorial 3-2018-19, specially from pp. 21.13 / 16Question II-B, The motion of a single-mass suspension model of the vehiclesuspension system.(20 Marks)Consider the single-mass suspension model shown in Figure II-B.1, which is typicalrepresentation of the vehicle suspension system. The spring and damper forces ???? and have the nonlinear models. When the vehicle strikes a bump, the road surface profilecan be represented by the trapezoidal function y(t) shown in Figure II-B.2. Now, thesystem model (derived from Newton’s law) becomes:is the is the nonlinear spring function shown in FigureII-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 tostate clearly:a) Answer a question: whether to use a state-variable representation, or a transferfunctionrepresentation, or nonlinear treatment, to create the correspondingmodel in Simulink, and why?(3 Marks)b) How is the Simulink model derived? In your report, you need to present (i) allthe 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 screenshots.(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 exportSimulink 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, whatquantities do you plot and units) and legends if applicable.(3 Marks)14 / 16Hints:a) The road surface profile, y(t) as shown in Figure II-B.2, which is the input to yourmodel, 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 (3rd 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 / 16Figure II-B.3. Nonlinear spring function.16 / 16Contribution Form – MATLAB Group AssignmentGroup____:Name andStudent IDnumberOverallcontribution(%)Problem analysisand equationderivations, etc.(%)MATLABprogramming(%)Report writing(%)CommentsA1234567837 40 60 10 For example: Lead in thecompletion of theassignment and contributethe most in MATLABprogrammingB1234567830 20 15 55 For example: Work closelywith other group members,contributes particularly inComponent 3.C1234567828 35 20 30 For example: Work closelywith other group members,contributes almost evenlyin Component 1 and 3.D123456785 5 5 5 For example: He/shecontributes 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 thegroup, and will also provide a basis for differentiate your marks (if there aresubstantial workload differences between team members). 转自:http://www.7daixie.com/2019043020186841.html