Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Meijer-G function .m file

831 views
Skip to first unread message

Gervais

unread,
May 11, 2013, 2:10:09 AM5/11/13
to
Hello to all,
I really need to simulate the Meijer-G function with Matlab. This function is supposed to be available in Matlab R2013a (since it is described in the online documentation), but I cannot find it, even after installing that new version.

Please, can you tell me what to do ? Better, could someone send me the .m file (meijerG.m) of that function?


Thanks you very much for your help.
Best Regards.

Nasser M. Abbasi

unread,
May 11, 2013, 2:39:35 AM5/11/13
to
This is mupad function.

type mupad, then in the new window type

meijerG([[1],[]], [[],[2]],x)

it should work now.

Matlab 2013a

--Nasser

Gervais

unread,
May 11, 2013, 3:38:07 AM5/11/13
to
"Nasser M. Abbasi" wrote in message <kmkp38$4qo$1...@speranza.aioe.org>...
Thank you very much for your answer.
I can effectively type the function in the new window. However, I cannot obtain numerical results with the meijerG function. I do not see I to do it.

In fact, I want to obain numerical results so that to evaluate the performance analysis of wireless communications networks. I then need to plot some figures for that end, and I do not know I could achieve it, even with the use of Mupad (the aforementioned window).

Thank you very much for your suggestions

Nasser M. Abbasi

unread,
May 11, 2013, 3:53:03 AM5/11/13
to
try evalin:

EDU>> x=4;
EDU>> evalin(symengine, sprintf('meijerG([[1],[]], [[.5],[.4]],%f)',x))

1.272701359518434436410056881777

EDU>> x=5;
EDU>> evalin(symengine, sprintf('meijerG([[1],[]], [[.5],[.4]],%f)',x))

1.2538810500643783439989037985641

etc..

--Nasser



Gervais

unread,
May 12, 2013, 3:26:08 PM5/12/13
to
"Nasser M. Abbasi" wrote in message <kmktd0$h2q$1...@speranza.aioe.org>...
Thank you again, very much.
Your tricks are really helpful.

Best Regards.

Alison

unread,
Oct 27, 2013, 4:08:11 PM10/27/13
to
Dear Nasser,

I've found on a Matlab forum where you advise someone to use Meijer-G in the following way:
evalin(symengine, sprintf('meijerG([[1],[]], [[.5],[.4]],%f)',x))
When I do that it works perfectly but I would like to use it in the following way
evalin(symengine, sprintf('meijerG([[A],[B]], [[C],[D]],%f)',x))
where A, B, C and D are variables computed by other function.
Could you help me telling what is my mistake?
Thanks!
Best Regards,
Alison

"Nasser M. Abbasi" wrote in message <kmktd0$h2q$1...@speranza.aioe.org>...

Nasser M. Abbasi

unread,
Oct 27, 2013, 7:56:01 PM10/27/13
to
On 10/27/2013 3:08 PM, Alison wrote:
> Dear Nasser,
>
> I've found on a Matlab forum where you advise someone to use Meijer-G in the following way:
> evalin(symengine, sprintf('meijerG([[1],[]], [[.5],[.4]],%f)',x))
> When I do that it works perfectly but I would like to use it in the following way
> evalin(symengine, sprintf('meijerG([[A],[B]], [[C],[D]],%f)',x))
> where A, B, C and D are variables computed by other function.
> Could you help me telling what is my mistake?
> Thanks!
> Best Regards,
> Alison
>

Just use subs().

But do not use the letter 'D' as it can conflict with internal
workings of syms. Use D0 if you must:

-----------------------
D0=1;C=2;A=.5;B=.4; %evaluated earlier by some other function
x=5;
r=evalin(symengine, sprintf('meijerG([[A],[B]], [[C],[D0]],%f)',x));
-------------------

meijerG([[1.0 - 1.0*C], [1.0 - 1.0*D0]], [[1.0 - 1.0*A], [1.0 - 1.0*B]], 0.2)

subs(r)

-0.37943899973412817863379462997932

--Nasser

Alison

unread,
Oct 27, 2013, 8:55:10 PM10/27/13
to
"Nasser M. Abbasi" wrote in message <l4k96h$7fs$1...@speranza.aioe.org>...
Dear Nasser,

Here is my real case:
evalin(symengine,sprintf('meijerG([[-0.25], [0.25]],[[0, .25, .5, .75],[-0.75]],%f)',w))
ans =
1.8759731320238564955620266437325
When I try to do
A_meijer=-0.25
B_meijer=0.25
C_meijer=[0, .25, .5, .75]
D_meijer=[-0.75]
r=evalin(symengine, sprintf('meijerG([[A_meijer],[B_meijer]], [[C_meijer],[D_meijer]],%f)',w));

I'm getting a different result. Would you know what is the problem?

>> subs(r)
ans =
[ 0.27220023582191846207903480097897, 0, -0.0058838347190451470885903180018307, -0.0014221740455809914698798645010017]

Furthermore, some times I have cases where A_,B_ or D_meijer can also be a vector.
Thanks a lot!
Regards,
Alison

Alison

unread,
Oct 27, 2013, 9:05:16 PM10/27/13
to
"Alison" wrote in message <l4kcld$cn1$1...@newscl01ah.mathworks.com>...
One last thing, my w = 0.00126124478414443

Nasser M. Abbasi

unread,
Oct 27, 2013, 10:02:06 PM10/27/13
to
On 10/27/2013 7:55 PM, Alison wrote:

> Here is my real case:
> evalin(symengine,sprintf('meijerG([[-0.25], [0.25]],[[0, .25, .5, .75],[-0.75]],%f)',w))
> ans =
> 1.8759731320238564955620266437325
> When I try to do
> A_meijer=-0.25
> B_meijer=0.25
> C_meijer=[0, .25, .5, .75]
> D_meijer=[-0.75]
> r=evalin(symengine, sprintf('meijerG([[A_meijer],[B_meijer]], [[C_meijer],[D_meijer]],%f)',w));
>
> I'm getting a different result. Would you know what is the problem?
>
>>> subs(r)
> ans =
> [ 0.27220023582191846207903480097897, 0, -0.0058838347190451470885903180018307, -0.0014221740455809914698798645010017]
>
> Furthermore, some times I have cases where A_,B_ or D_meijer can also be a vector.
> Thanks a lot!
> Regards,
> Alison
>

Your C is a vector, not one element. mupad wants list in its meijerG.
So subs does not work in this case.

If you really intend to do a little bit more advanced stuff like this,
it makes more sense to use mupad directly. (type mupad in Matlab)
having having to deal with passing things back and forth between
Matlab and mupad. It is very awkward way of doing things.

good luck,
--Nasser

Raj Raj

unread,
Apr 15, 2014, 1:08:12 AM4/15/14
to
"Nasser M. Abbasi" wrote in message <l4kgit$m4p$1...@speranza.aioe.org>...
Hi There,

I would be greatful to get adressed for a similar issue:
f1 =@(alpr) evalin(symengine, 'meijerG([[0, 1/2], []], [[1, 0], [-1, -1]], alpr(1)*alpr(2))');
How to evaluate the function f1 for a give values of alpr as alpr = [1, 2].

I failure to substitute the vaules into this mupad expression in matlab workspace.

Appreciate your response.

Regards
Raj

Nasser M. Abbasi

unread,
Apr 15, 2014, 2:34:30 AM4/15/14
to
On 4/15/2014 12:08 AM, Raj Raj wrote:

> I would be greatful to get adressed for a similar issue:
> f1 =@(alpr) evalin(symengine, 'meijerG([[0, 1/2], []], [[1, 0], [-1, -1]], alpr(1)*alpr(2))');
> How to evaluate the function f1 for a give values of alpr as alpr = [1, 2].
>
> I failure to substitute the vaules into this mupad expression in matlab workspace.
>

---------------------
clear all;
f1 =@(alpr) evalin(symengine, ...
sprintf('meijerG([[0, 1/2], []], [[1, 0], [-1, -1]], %f)', alpr(1)*alpr(2)))
alpr = [1, 2];
f1(alpr)
-----------------

ans =

1.2511190936149650392077692632015

--Nasser


Raj Raj

unread,
Apr 15, 2014, 3:09:08 AM4/15/14
to
"Nasser M. Abbasi" wrote in message <liijtl$4v6$1...@speranza.aioe.org>...
Hi Nasser,

Thanks alot for your input.

I have been trying with feval and struggling...

A little extension to the above case may be like this. Can I substitute only one variable, alpr(2). As I need to find the second variable, alpr(1) from another equation:

clear all;
f1 =@(alpr) evalin(symengine, sprintf('meijerG([[0, 1/2], []], [[1, 0], [-1, -1]], %f)', alpr(1)*alpr(2)))
alpr = [alpr(1), 2];
f1(alpr)

However, this function evaluation is not allowed.

Thanks in advance.
Regards
Raj

George Feghaly

unread,
May 27, 2015, 3:29:54 AM5/27/15
to
Hello Nasser,

Hope you are fine and doing well.

Could you please reply on my question below link:
http://www.mathworks.com/matlabcentral/answers/219352-how-to-write-the-attached-meijerg-function-in-matlab

Nasser M. Abbasi

unread,
May 27, 2015, 4:03:24 AM5/27/15
to
I am not following. What is the question?

I run the code you have, and it works.

---------------------
an=[];
ap=[];
bm=0;
bq=[0.5];

z=((1.04719755)^2)/4;

x= MeijerG( an, ap, bm, bq, z )
------------------------

x =
0.2821


Which matches direct call

--------------------------------------
>> evalin(symengine, 'meijerG([],[],[0],[0.5],0.2742)')

ans =

0.28205343264689752196411883903024 + 7.5897407713298780497953407455652e-44i

>> double(ans)

0.2821 + 0.0000i

-----------------------------------------------

So I really do not understand what you are asking.

--Nasser


Akarsh Sundareswar Pokkunuru

unread,
Aug 18, 2016, 12:39:15 PM8/18/16
to
"Nasser M. Abbasi" wrote in message <mk3to4$d5k$1...@speranza.aioe.org>...
Hello Mr. Nasser

I have a similar question regarding Meijer G function. I would really appreciate your advice on this topic.
I have the G-function representation of the form given below -

summation " i " from 0 to infinity
G(3,1,2,3) [ k+1/v | -1-i, -i, 0, -1-i, -1-i ]

Here, the summation variable " i " varies from 0 to infinity inside the G function and also k and v are real numbers.

How do i express the above function using matlab code?
Hope you can provide some advice.

Thank you,
Akarsh

Nasser M. Abbasi

unread,
Aug 19, 2016, 2:44:41 AM8/19/16
to
On 8/18/2016 11:39 AM, Akarsh Sundareswar Pokkunuru wrote:

>
> I have a similar question regarding Meijer G function. I would
>really appreciate your advice on this topic.
> I have the G-function representation of the form given below -
>
> summation " i " from 0 to infinity
> G(3,1,2,3) [ k+1/v | -1-i, -i, 0, -1-i, -1-i ]
>
> Here, the summation variable " i " varies from 0 to infinity inside
>the G function and also k and v are real numbers.
>
> How do i express the above function using matlab code?
> Hope you can provide some advice.
>
> Thank you,
> Akarsh
>

I am not able to parse your question correctly. I do not understand
what

> summation " i " from 0 to infinity
> G(3,1,2,3) [ k+1/v | -1-i, -i, 0, -1-i, -1-i ]

means. I do not understand the notation used. sorry.

--Nasser

Akarsh Pokkunuru

unread,
Aug 22, 2016, 3:38:11 PM8/22/16
to
"Nasser M. Abbasi" wrote in message <np69sf$15b2$1...@gioia.aioe.org>...
Hello Mr. Nasser

Thank you for the immediate reply. Please click on the link below -

http://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=1388718

The Meijers G function I am referring to is in equation (5). I am trying to plot the equation (5) using matlab.

Thank you,

Akarsh

Akarsh Pokkunuru

unread,
Aug 24, 2016, 3:37:09 PM8/24/16
to
"Akarsh Pokkunuru" <akarsh...@gmail.com> wrote in message <npfkau$ic4$1...@newscl01ah.mathworks.com>...
Hello Mr. Nasser

The above paper used Wolfram mathematica to write that function and that is why the notation is a bit different.
Anyway this is the expression closest to what I could write in mupad interface for the above Meijers G function -

sum(meijerG([[],[-1-n,-n]], [[0],[-1-n,-1-n]],(k-1)/v), n=0..infinity)

(K - 1)/v is an array of values which will be plugged into the above expression.

However its a bit different from the equation in paper. What is the mistake I am doing?

Thank you

Steven Lord

unread,
Aug 26, 2016, 11:17:39 AM8/26/16
to


"Akarsh Pokkunuru" <akarsh...@gmail.com> wrote in message
news:npkt0v$g00$1...@newscl01ah.mathworks.com...

*snip*

> Hello Mr. Nasser
>
> The above paper used Wolfram mathematica to write that function and that
> is why the notation is a bit different.
> Anyway this is the expression closest to what I could write in mupad
> interface for the above Meijers G function -
>
> sum(meijerG([[],[-1-n,-n]], [[0],[-1-n,-1-n]],(k-1)/v), n=0..infinity)
>
> (K - 1)/v is an array of values which will be plugged into the above
> expression.
>
> However its a bit different from the equation in paper. What is the
> mistake I am doing?

Sometimes mathematical papers or books or different mathematical software
packages use different conventions for special function inputs and
formulations. For example in MATLAB the Bessel function of the first kind,
BESSELJ, accepts the order of the Bessel function as the first input
argument and the argument at which you want to evaluate the Bessel function
as the second input.

http://www.mathworks.com/help/matlab/ref/besselj.html

On the other hand, Microsoft Excel's version of that function requires the
argument as the first input and the order as the second.

https://support.office.com/en-us/article/BESSELJ-function-839cb181-48de-408b-9d80-bd02982d94f7

So if you blindly tried to evaluate J_2(1) in both MATLAB [as besselj(1, 2)]
and Microsoft Excel [as =BESSELJ(1, 2)] you would receive very different
results. But the answer you received from MATLAB for besselj(1, 2) should
agree with the answer you receive if you ask Excel to compute =BESSELJ(2,
1).

Make sure you're comparing apples to apples with respect to the order and
meaning of the inputs to meijerG. If after doing so you're still seeing
significant differences, please simplify your code down to a small number
(5-10 at most) lines of code that demonstrate the difference between
MuPAD/MATLAB and Mathematica and send that code to Technical Support for
investigation.

--
Steve Lord
sl...@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

a21...@iiit-bh.ac.in

unread,
Feb 5, 2017, 12:04:57 AM2/5/17
to
Hello
I need some help regarding implementing meijerG function using mupad and interfacing it with Matlab .
With reference to the discussions here I have tried implementing .however ,I am finding issues while calling it from Matlab using evalin .your help for the same will be obliged.
Regards
Preeti

a21...@iiit-bh.ac.in

unread,
Feb 5, 2017, 12:21:23 AM2/5/17
to
Hello
I am trying to implement equation 10 of the below link using mupad and interface it with Matlab .however ,I am unable to know how to pass the sequence of arguments to exactly get this implementation .A little help regarding the same will oblige


https://www.researchgate.net/publication/265128709_Performance_analysis_of_FSO_links_under_Strong_atmospheric_turbulence_conditions_using_various_modulation_schemes

Regards
Preeti

f201...@pilani.bits-pilani.ac.in

unread,
May 1, 2020, 1:56:15 AM5/1/20
to
Hi Preeti,
I have doubts with similar equations as yours, have you been able to implement the equation in MATLAB. It will be great if you could help.

Thanks,
Megha
0 new messages