MATLAB: MeijerG function using MATLAB’s symbolic toolbox

meijerg-functionmupadSymbolic Math Toolboxsymbolic toolbox

I want to know whether there is anyway I can use MeijerG functions in Matlab scripts using symbolic toolbox. Specifically, MeijerG functions describe the probability densities and it is easier to work with them. Currently, I use Maple to get the results and then retype them in Matlab. But, I am unable to use them in symbolic toolbox

Best Answer

As of R2017b, the function "meijerG" calculates the Meijer G-Function. This function can return either numerical values or symbolic expressions for the Meijer G-Function depending upon the input.
For 'double' inputs, "meijerG" returns a double, as shown below: 
     >> meijerG(3, [], [], [], 3)
     ans =
         6.4488
For 'sym' inputs, "meijerG" will return an exact symbolic answer whenever possible. An example is shown below:
     >> meijerG(sym(2/5), [], sym(1/2), [], sym(3))
 
     ans =
 
     (2^(4/5)*3^(1/2)*gamma(1/10))/80
The documentation linked below has more details about "meijerG"'s full functionality:
For prior releases, the symbolic MeijerG function is only available in MuPAD. From MATLAB, it must be evaluated using "evalin", as shown below:
     >> y=evalin(symengine, 'simplify(meijerG([[3],[]], [[],[]],3))'); 
     y =
 
     9*exp(-1/3)
Once this command executes, 'y' will contain symbolic MeijerG function for given arguments.
Note that without the call to "simplify", an expression in terms of the MuPAD function "meijerG" may be returned, which will not be understood by MATLAB in further function calls. You can pass this back to "evalin" by first converting it with the "char" function, but this workflow is not recommended.