Question: % % Project Five % [ YOUR NAME ] % [ Any Collaborators ] % % Instructions % RUN THE CODE TO CONFIRM THAT IT

%% Project Five
%[YOUR NAME]
%[Any Collaborators]
%% Instructions
% RUN THE CODE TO CONFIRM THAT IT WORKS
% INCLUDE YOUR ANSWER TO QUESTION 1 AS A COMMENT
% ADD AND MODIFY THE CODE WHERE INDICATED
% INCLUDE YOUR ANSWER TO QUESTION 2 AS A COMMENT
% ADD AND MODIFY THE CODE WHERE INDICATED
% INCLUDE YOUR ANSWER TO QUESTION 3, ALONG WITH ANY SUPPORTING MATERIALS,
% AS A COMMENT
% USE THE Publish TAB TO SAVE YOUR RESULTS AS A PDF
%% Initialize
% These commands clear the workspace and close any figures, to make sure
% that previous versions of the code do not effect the current run.
% They are not always necessary, and may noticably slow large progams.
clear all;
close all;
%% Solve the ODE y"+c*y'+ omega0^2*y = cos(omega*t) given y(0)=0, y'(0)=0,
and omega =1.4
omega0=2; c =1; omega =1.4; % define parameters
param =[omega0,c,omega]; % convert parameters into form usable by ODE45
t0=0; y0=0; v0=0; Y0=[y0;v0]; tf =50; % define interval and intial
condition
options = odeset('AbsTol',1e-10,'RelTol',1e-10); % adjust tolerance/precision of
ODE45
[t,Y]= ode45(@f,[t0,tf],Y0,options,param);
y = Y(:,1); v = Y(:,2); % y in output has 2 columns corresponding to y and y'
figure(1); % starts a new figure
plot(t,y,'b-'); % graph solution
grid on; % display grid
%% Question 1
% What is the long term behavior of the solution? (Be as exact as
% possible. You may wish to use the ZOOM feature in the Figures.)
%
%[INSERT ANSWER HERE]
%% Solve the ODE for omega =2
%[INSERT MODIFIED CODE TO GRAPH THE SOLUTION OF THE ODE WITH omega =2 IN
% Figure(2) HERE]
%% Question 2
% How has the solution changed? (Be as exact as possible. You may wish to
% use the ZOOM feature in the Figures.)
%
%[INSERT ANSWER HERE]
%% Solve the ODE for omega =2.6
%[INSERT MODIFIED CODE TO GRAPH THE SOLUTION OF THE ODE WITH omega =2.6 IN
% Figure(3) HERE]
%% Question 3
% How has the solution changed compared to the previous two solutions?
% What do you expect will happen as omega continues to increase? (Be as
% exact as possible. You may wish to use the ZOOM feature in the Figures.
% If you run any simulations to confirm your hypothesis, be sure to include
% them in the report.)
%
%[INSERT ANSWER HERE]
%% Terminate
% SOME students running SOME versions on SOME platforms have had issues
% with the last table or figure not appearing in the PUBLISH document.
% This workaround appears to fix it for most, but be aware and always check
% your results before submitting them for grade.
term = true;
%% Functions
function dYdt = f(t,Y,param)
y = Y(1); v = Y(2);
omega0= param(1); c = param(2); omega = param(3);
dYdt =[ v ; cos(omega*t)-omega0^2*y-c*v ];
end
(answer the questions specific as possible using the results from the graphs produced and also fix the code)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!