eigen values for all sol of ode45 ouput after finding the jacobian using symbolic syms command
1 view (last 30 days)
Show older comments
Hello everyone,
I am having a system with 2 differentail equations .I am using ode45 to get x ie i have t and x as column vectors of ode45 solver ouput.
I want to compute the eigen values of the system with that solution.I use a function using symbolic to find the jacobian .
But i dont know how to pass the output of ode45 sol ie x into the function to get the eigen values.
Main program:
clear all
clc;
Tspan =[0 1];
X0=[0.0; 1]; % Initial condition
%solving the differential Equation
[t,x]=ode45(@myfunc,Tspan,X0);
%Plotting the figures
figure(1)
subplot(2,1,1)
plot(t(:,1),x(:,1))
xlabel('t');
ylabel('x1');
grid on
subplot(2,1,2)
plot(t(:,1),x(:,2))
xlabel('t');
ylabel('x2')
grid on
x % Here i have array of x
% Finding the eigen values
e=findeig(x)
ODE FUNTION:
function dv=myfunc(t,x,flag)
%The Diffenrential Equation
dv=[ (x(1))+(x(2)*x(2));%x1dot Equation
x(1)-x(2); ]; % x2dot Equation
function to calculate EIGEN VALUES:
function e=findeig(x)
syms x1 x2
%The Diffenrential Equation
f1= (x1)+(x2*x2);%x1dot Equation
f2=x1-x2; % x2dot Equation
f = [f1, f2];
Jac = jacobian(f)
x1=x(:,1);
x2=x(:,2);
q=eval(Jac)
op=eig(q)
I am getting the output as
x =
0 1.0000
0.0001 0.9999
0.0001 0.9999
0.0002 0.9998
0.0002 0.9998
0.0005 0.9995
0.0007 0.9993
................. (57x2 ) array.
Jac =
[ 1, 2*x2] [ 1, -1]
??? Error using ==> horzcat CAT arguments dimensions are not consistent.
Error in ==> sym.eval at 15 s = evalin('caller',vectorize(map2mat(char(x))));
Error in ==> findeig at 15 q=eval(Jac)
Error in ==> MainProgram at 25 e=findeig(x)
0 Comments
Answers (0)
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!