Search code examples
matlabsymbolic-math

Laplace transform of equation from "fit"


This is a follow-up on a previous question by myself: Laplace transform of numerical data in MATLAB


I have experimentally collected data, and want to take a Laplace transformation of that. However, laplace() needs a model/equation. I find a fit equation to model my data from:

[up,lo] = envelope(dat);

x = 1:length(up);
x = x';

f = fit(x,up,'poly3');

Then for my Laplace transform I need to I pass the output of

f = fit(x,up,'poly3');

into

syms f
laplace(f)

However at the moment this spits out the transform of f:

laplace(f)

ans =

1/s^2

If this is f

f = 

     Linear model Poly3:
     f(x) = p1*x^3 + p2*x^2 + p3*x + p4
     Coefficients (with 95% confidence bounds):
       p1 =   1.772e-12  (1.593e-12, 1.951e-12)
       p2 =  -2.211e-08  (-2.483e-08, -1.939e-08)
       p3 =   2.847e-05  (1.676e-05, 4.017e-05)
       p4 =      0.2762  (0.2627, 0.2897)

How do I find the Laplace transform of f?


Solution

  • I'm not familiar with the output of fit, but your symbolic variable at least should be x, as that's your dependent variable. You can then build up the f yourself:

    p1 =   1.772e-12;
    p2 =  -2.211e-08;
    p3 =   2.847e-05;
    p4 =      0.2762;
    
    syms x
    
    f = p1*x.^3 + p2*x.^2 + p3*x + p4;
    
    laplace(f)
    ans =
    
    (8402860860456175*((50949907131585781563392*s)/5251788037785109375 + 1))/(295147905179352825856*s^2) - 6682337467919863/(151115727451828646838272*s^3) + 26323556995364325/(2475880078570760549798248448*s^4)
    

    fit() gives you a fitobject type variable, which, if I understand its documentation correctly, can be accessed as a structure. This means that you should be able to programmatically use the fitted parameters to build your function of symbolic x.