C_a_t =

Hi @John,
I took a look at your gamma distribution Laplace inversion problem, and you've hit a classic limitation of MATLAB's symbolic inverse Laplace transform capabilities. The issue arises because non-integer values for the 'n' parameter produce non-integer exponents, and while MATLAB can transform time expressions with non-integer exponents into Laplace space, combining those with other expressions creates results that cannot be analytically inverted, even with partfracand simplify functions.
So, the root problem that we are dealing here with, when n is non-integer (like 1.1), your gamma distribution expression:
E_t(N)=((1/tbar)*(((t)/tbar)^(n-1))*((n^n)/gamma(n))*exp(-n*(t)/tbar));
produces fractional powers that create complex symbolic expressions in the Laplace domain. The symbolic ilaplacefunction simply can't handle the analytical inversion of such expressions when they're combined with your other terms in C_a_s(N).
My suggestion would be at this point for you to try switching to numerical inverse Laplace methods. Here are your best options:
1. Numerical Inverse Laplace Transform Toolbox MATLAB File Exchange offers numerical inverse Laplace transform methods including Euler and Talbot algorithms, with both regular and symbolic versions for higher precision.
Download from: https://www.mathworks.com/matlabcentral/fileexchange/39035-numerical-inverse-laplace-transform
2. Gaver-Stehfest Algorithm The Gaver-Stehfest algorithm is specifically designed for inverse Laplace transforms of arbitrary functions and works well with gamma distributions.
Available at:
3. Modified Code Approach Here's how you could modify your approach: % After computing C_a_s(N), use numerical inversion instead of ilaplace % Download one of the numerical inverse Laplace functions first
% For example, using Talbot method: % Define time vector t_vec = linspace(0, 60, 1000);
% Convert symbolic expression to function handle C_a_s_func = matlabFunction(C_a_s(N), 'Vars', s);
% Apply numerical inverse Laplace for i = 1:length(t_vec) C_a_t_numerical(i) = talbot_inversion(C_a_s_func, t_vec(i)); end
% Plot results plot(t_vec, C_a_t_numerical);
The alternative semi-analytical approach for you, if you want to stay closer to analytical methods, consider:
1. Using rational approximations for the gamma function with non-integer parameters 2. Breaking your problem into simpler components that can be inverted separately 3. Using series expansions around integer values of n
As far as performance considerations goes, the Talbot method is generally high accuracy and fast, but can fail catastrophically for certain time-domain behaviors like Heaviside step functions or some oscillatory behaviors. The Gaver-Stehfest method tends to be more robust for a wider range of functions. I'd recommend starting with the Gaver-Stehfest algorithm since it's specifically designed for cases like yours where analytical inversion fails.
References:
Hope this helps.
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!