1

I have applied inverse laplace transform to a matrix and now it is a function of t. My goal is to substitute t value and get the result matrix. I intended this code to be pretty straight foward but I'm not getting it work. This is what I tried:

clc,clear all, close all

% Parameters
syms s
r=3.33;
l = 4.56*10^-3;
j = 4.96*10^-5;
b = 4.59*10^-5;
k = 0.0332;

% State Matrices
F = [-r/l -k/l 0; k/j -b/j 0; 0 1 0]
G = [1/l; 0; 0]


sI = s*eye(3,3)
aux_A = (adjoint(sI-F))/det(sI-F)
laplaceA = ilaplace(aux_A)

result_matrix = @(t) laplaceA

%Assuming t = 0.01
result_matrix(0.01)
 

Assuming that my goal is just substitute t values within laplaceA matrix, I am open to any suggestions. Thanks!

MichaelTr7
  • 4,737
  • 2
  • 6
  • 21
Rezik
  • 31
  • 5

1 Answers1

1

Replacing syms Variables in Symbolic Functions

Using subs() to substitute the Input parameter of the anonymous function/function handle may be as way to replace all the t terms in laplaceA. Modifying the single line to be as follows should give numerical results without any t variables:

result_matrix = @(Input) subs(laplaceA,"t",Input);

To evaluate the trigonometric functions to numerical values

result_matrix = @(Input) vpa(subs(laplaceA,"t",Input));

Full Script:

clc
clear
close all

% Parameters
syms s
r = 3.33;
l = 4.56*10^-3;
j = 4.96*10^-5;
b = 4.59*10^-5;
k = 0.0332;

% State Matrices
F = [-r/l -k/l 0; k/j -b/j 0; 0 1 0];
G = [1/l; 0; 0];


sI = s*eye(3,3);
aux_A = (adjoint(sI-F))/det(sI-F);
laplaceA = ilaplace(aux_A);

result_matrix = @(Input) vpa(subs(laplaceA,"t",Input));

%Assuming t = 0.01
result_matrix(0.01)

Output Results:

Output Results

MichaelTr7
  • 4,737
  • 2
  • 6
  • 21