Matlab programing
write math lab programing with the instruction on the attachment
This project consists of two parts. Your project report should be turned in to the drop box in D2L. Part I (20 points) Solution of 2 nd Order Homogeneous Differential Equations of the form: ( ) 2 2 by r t dt dy a dt d y Creating a 2nd Order Function in Matlab Under the File Pulldown Menu Select New > mfile(a new window will appear) Enter the following function into this file and save it function dydt = order2(t,y) dydt = zeros(size(y)); a = 4.0; %coefficient for y’ term b = -2.0; %coefficient for y term r = 0.0; %forcing function dydt(1) = y(2); dydt(2) = r -a*y(2) – b*y(1); Explanation of above function a is the coefficient for dt dy term b is the coefficient for y term r is the right hand side (forcing function) which is equal to 0 in this case dydt(1) = y(2) (let y = y(1) , y’ = y(2)) dydt(2) = r -a*y(2) – b*y(1); (solve for y(2)’ in terms of r, y and y’ terms) Note: we have converted a 2nd order ODE to two 1st order ODE’s. In the Matlab window enter the following lines >> tspan = [0 2]; >> y0 = [4,-5]; >> [t,y]=ode45(@order2,tspan,y0); >> plot(t,y(:,1)) tspan provides the range of the time. y0 provides the initial conditions with its first element = y(0), second element = y’(0) ode45 is a Matlab routine which solves the ordinary differential equation. The routine gives discrete values of y for each value of t. These results are then plotted. Compare your Matlab figure to Fig. 30 on page 55 of your text [Fig. 29 on page 54 of 9 th Ed. text]. Notice that the damping coefficient is four times of that of Fig. 30 [Fig. 29 in 9th Ed. of text]. Open a word document and type your name at the top of the file. Copy your m file and Matlab figure into it and type your comments for your observation, Change the initial conditions in y0. Repeat the final 2 Matlab commands from above. Observe how the plots change. Add the plots with y0 = [4,-1] and y0 = [1,-5] along with comments for your observations to the word document and submit it to the project 2 D2L drop box. Save your m-file. You will be modifying this file in the next part. Part II (20 points) 1. Modify your prior code and save the new m-file after modifications, then set tspan = [0 10] and solve: t y te dt dy dt d y 1.6 2 2 3.2 2.56 10 with y(0) 1, y (0) 0. Compare your Matlab figure to Fig. 51 on page 83 of your text [Fig. 50 on page 82 of 9 th Ed. text]. Open a new word document and type your name at the top of the file and copy your m file and Matlab figure into it and type your observation. 2. Resonance Given an equation of the form ( ) 2 2 ky r t dt dy c dt d y m where m , k 48, with initial conditions y(0) 1 and y (0) 0. Also set tspan = [0 40] and let ( ) 12cos( ) * r t t where 2 2 * 4m c m k for underdamping case or r(t) 5cos( t) o with m k o for undamped case. Notice that y x is sqrt(x/y) in Matlab. Modify your prior code (notice that you need to convert the spring mass ODE into the form of ODE with the coefficient of y” equal to 1, similar to the 1st equation in Part I on page 1 ) and run your program several times with the following values for c and r(t) (copy the m file and figure of this run to the word file created in 1. of part 1I): a) c=16 and use an appropriate r(t) b) c=1.6 and use an appropriate r(t) c) c=0.16 and use an appropriate r(t) d) c=0.16 and change ( ) 12cos(0.9 ) * r t t , i.e. detuning the input frequency 10% away from the resonant frequency. Compare to Figs. 55—57 (on page 88—91) [Figs. 54—56 in 9th Ed. of the text (on page 87— 90)], do you see the trend indicated by these figures? Put your comments in the word file and then submit it to the D2L drop box for project 2. Note: Save the m-file after modifications of ODE parameters such as coefficients and r(t) each time. Open a new word document and type your name at the top of the file. Copy your m-file and Matlab figure into it and type your observation for each part.
"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.
Discount Code: CIPD30
Click ORDER NOW..


