Question: matlab code: clear % % Initial data num _ y ( 1 , 1 ) = input ( Input initial condition y 1 _

matlab code:
clear
%
% Initial data
num_y(1,1)= input("Input initial condition y1_0=");
num_y(1,2)= input("Input initial condition y2_0=");
% Time interval [ti,tf]
ti = input("initial time =");
tf = input("final time =");
nt = input("number of time steps =");
dt=(tf-ti)/nt;
% Input matrix A for the 2x2 system dy/dt = A y
A(1,1)= input("matrix coefficient A11=");
A(1,2)= input("matrix coefficient A12=");
A(2,1)= input("matrix coefficient A21=");
A(2,2)= input("matrix coefficient A22=");
disp("Display matrix eigenvalues")
eig(A)
B= eye(2)+ dt * A;
x(1)=ti;
for i=2:nt+1,
num_y(i,1:2)= num_y(i-1,1:2)* B;
x(i)=ti+(i-1)*dt;
end
subplot(211), plot(x,num_y(:,1)),...% indicates line continuation
title(y1(t)),xlabel(t),grid,...
subplot(212),plot(x,num_y(:,2)),...
title(y2(t)),xlabel(t),grid
matlab code: clear % % Initial data num _ y ( 1 ,

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!