MATLAB won’t invert a function in the Laplace domain…
We are using a fairly simple function of the gamma distribution. When I use whole numbers for the "n" parameter, MATLAB inverts the function well. However, when I use non-integer values for n (e.g., n=11/10 or 1.1), MATLAB is unable to invert the function.
Here is the error message:
Warning: Error in state of SceneNode. The following error was reported evaluating the function in FunctionLine update: Unable to convert symbolic expression to double array because it contains symbolic function that does not evaluate to number. Input expression must evaluate to number.
I want to be able to use various values of n that are not integers.
Here is my code.
Do I need to use a numerical inversion method? or is there a simple means of fixing this withing MATLAB?
% Clear all variables and close all plots.
clc
close all;
clear all;
% Declare the variables that are symbolic.
syms t s N n m r t_close tbar
syms E_t E_s Day_hours
syms C_a_s C_a_t Fun_s
% Define the values of the model parameters
tbar=8; % tbar is one of the gamma distribution parameters.
n=1; % n is the second of two parameters needed to
% define the gamma distribution shape. set n=1.1, and it
% does not work.
Day_length=24;
r=0.5;
t_close=8;
m=sym(tbar/t_close);
% N is the number of cycles for which we
% want this to run. For now, one cycle is
% enough to determine whether this will work.
for N=1
% Define the gamma distribution
E_t(N)=((1/tbar)*(((t)/tbar)^(n-1))*((n^n)/gamma(n))*exp(-n*(t)/tbar));
% Transform the gamma distribution into the Laplace domain
E_s(N)=laplace(E_t(N));
% Define a function that is a result of a derivation
Fun_s(N)=(exp(-Day_length*(N-1)*s))/s-exp((-Day_length*(N-1)-t_close)*s)/s;
% Define the concentration function in the Laplace domain
C_a_s(N)=(m/(tbar*s))*((1-E_s(N))/(1-r*E_s(N)))*Fun_s(N);
% Now, take the inverse laplace of the concentration function to
% put it in the time domain.
% if n is not an integer, it won’t invert the function.
% any ideas???
C_a_t(N) = ilaplace(C_a_s(N),s,t)
fplot(C_a_t(N),[0 60])
endWe are using a fairly simple function of the gamma distribution. When I use whole numbers for the "n" parameter, MATLAB inverts the function well. However, when I use non-integer values for n (e.g., n=11/10 or 1.1), MATLAB is unable to invert the function.
Here is the error message:
Warning: Error in state of SceneNode. The following error was reported evaluating the function in FunctionLine update: Unable to convert symbolic expression to double array because it contains symbolic function that does not evaluate to number. Input expression must evaluate to number.
I want to be able to use various values of n that are not integers.
Here is my code.
Do I need to use a numerical inversion method? or is there a simple means of fixing this withing MATLAB?
% Clear all variables and close all plots.
clc
close all;
clear all;
% Declare the variables that are symbolic.
syms t s N n m r t_close tbar
syms E_t E_s Day_hours
syms C_a_s C_a_t Fun_s
% Define the values of the model parameters
tbar=8; % tbar is one of the gamma distribution parameters.
n=1; % n is the second of two parameters needed to
% define the gamma distribution shape. set n=1.1, and it
% does not work.
Day_length=24;
r=0.5;
t_close=8;
m=sym(tbar/t_close);
% N is the number of cycles for which we
% want this to run. For now, one cycle is
% enough to determine whether this will work.
for N=1
% Define the gamma distribution
E_t(N)=((1/tbar)*(((t)/tbar)^(n-1))*((n^n)/gamma(n))*exp(-n*(t)/tbar));
% Transform the gamma distribution into the Laplace domain
E_s(N)=laplace(E_t(N));
% Define a function that is a result of a derivation
Fun_s(N)=(exp(-Day_length*(N-1)*s))/s-exp((-Day_length*(N-1)-t_close)*s)/s;
% Define the concentration function in the Laplace domain
C_a_s(N)=(m/(tbar*s))*((1-E_s(N))/(1-r*E_s(N)))*Fun_s(N);
% Now, take the inverse laplace of the concentration function to
% put it in the time domain.
% if n is not an integer, it won’t invert the function.
% any ideas???
C_a_t(N) = ilaplace(C_a_s(N),s,t)
fplot(C_a_t(N),[0 60])
end We are using a fairly simple function of the gamma distribution. When I use whole numbers for the "n" parameter, MATLAB inverts the function well. However, when I use non-integer values for n (e.g., n=11/10 or 1.1), MATLAB is unable to invert the function.
Here is the error message:
Warning: Error in state of SceneNode. The following error was reported evaluating the function in FunctionLine update: Unable to convert symbolic expression to double array because it contains symbolic function that does not evaluate to number. Input expression must evaluate to number.
I want to be able to use various values of n that are not integers.
Here is my code.
Do I need to use a numerical inversion method? or is there a simple means of fixing this withing MATLAB?
% Clear all variables and close all plots.
clc
close all;
clear all;
% Declare the variables that are symbolic.
syms t s N n m r t_close tbar
syms E_t E_s Day_hours
syms C_a_s C_a_t Fun_s
% Define the values of the model parameters
tbar=8; % tbar is one of the gamma distribution parameters.
n=1; % n is the second of two parameters needed to
% define the gamma distribution shape. set n=1.1, and it
% does not work.
Day_length=24;
r=0.5;
t_close=8;
m=sym(tbar/t_close);
% N is the number of cycles for which we
% want this to run. For now, one cycle is
% enough to determine whether this will work.
for N=1
% Define the gamma distribution
E_t(N)=((1/tbar)*(((t)/tbar)^(n-1))*((n^n)/gamma(n))*exp(-n*(t)/tbar));
% Transform the gamma distribution into the Laplace domain
E_s(N)=laplace(E_t(N));
% Define a function that is a result of a derivation
Fun_s(N)=(exp(-Day_length*(N-1)*s))/s-exp((-Day_length*(N-1)-t_close)*s)/s;
% Define the concentration function in the Laplace domain
C_a_s(N)=(m/(tbar*s))*((1-E_s(N))/(1-r*E_s(N)))*Fun_s(N);
% Now, take the inverse laplace of the concentration function to
% put it in the time domain.
% if n is not an integer, it won’t invert the function.
% any ideas???
C_a_t(N) = ilaplace(C_a_s(N),s,t)
fplot(C_a_t(N),[0 60])
end inversion of a laplace transform MATLAB Answers — New Questions