Question
Hello I need a MATLAB help, Am working on my Systems and Controls exercise where we are analyzing first and second ordinary differential equation (ODE)
Hello I need a MATLAB help, Am working on my Systems and Controls exercise where we are analyzing first and second ordinary differential equation (ODE) using ode45. We are suppose to create a function named second order for the main code to call. I am having trouble with that and your help would be greatly appreciated . I have copied the functions code at the bottom of the main code. I will attach the instructions and my code below, Thank you.
%% Behavior of second order ODEs % y'' + a1*y' + a0*y = 0 % x' = Ax
T = 10; % the duration of the simulation a = [1,1]; % the parameter for the linear model: y'' + a1*y' + a0*y = 0 y0 = [1,1]; % the initial values of y and y': y'(0) = y0(1), y(0) = y0(2) t = linspace(0,T,Ns(j)); % initialize the time vector y = zeros(2,Ns(j)); % initialize the y vector y(1) = y0(2); % set the initial value of y to y0 figure(3); % opens a new figure indexed 3 [t,y] = ode45(@(t,y)second_order(t,y,a1,a0,y0),t,y0); plot(t,y,'LineWidth',2); title(sprintf('Numerical Integration')); legend('N=10','N=25','N=50','N=100','N=500','N=1000','ode45'); legend('Location','best'); xlabel('t'); ylabel('y(t)');
function dy = second_order(t,y,a1,a0,y0) A =[0 1;-a1 a0];; end
1.3 Behavior of first order ODEs Reusing most of your code from the ode45 section above, we now want to explore the behaviors of first order ODEs of the form in (4). In particular, try many different values of k and yo to observe how the behavior changes. Make sure to try different levels of positive and negative values as well as zero value. Make plots to demonstrate the different types of behavior and write a few sentences to describe how different ranges of these parameters lead to different behavior. Your plots should have axis labels and clear legends. One way to make nice legends and titles programmatically is to use the command sprintf. This command takes in a string with special characters that denote where to insert values from variables, followed by the variables in the same order. For example, pts 100 title ( sprintf('1 2 %s I get at least %1.2f out of %i on this lab,','hope',95.23,pts) ; would produce the output 1 I hope I get at least 95.23 out of 100 on this lab. As you can see values are inserted at points marked with a %. The string"%s' inserts a variable as a string; '%i' as an integer, and %1.2 as a float with 2 decimal places (the number of decimal places can be changed by changing the number 2) 3Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started