"Zac " <30988z2@gmail.com> wrote in message <i7m5v3$adi$1@fred.mathworks.com>...
> Hi,
>
> I am plotting the data
>
> 4*exp(2*x  y)
>
> as a probability density function. It has limits of
>
> 0<x and 0<y<2x
>
> I can't figure out how to tell Matlab these limits. The 'greater than zero' one is easy enough, I just make my meshgrid to go between zero and out to where it gets less interesting.
>
> In my desperation I even tried to multiply the whole function by
>
> (((2*xy)/abs(2*xy))+1)/2
>
> (i.e make all values zero at the points where y is greater than 2x) but this didn't work.
>
> I can't get the pdf function to do any better.
> Any help on how to get this to work would be appreciated.
>
> Thank you,
>
> Zac
        
I assume you are trying to make a surface plot of this function with the surf function. Just define the auxiliary variable t = y/(2*x) and make a meshgrid of x and t. Then convert to x and y.
[X,T] = meshgrid(linspace(0,interesting),linspace(0,1));
Y = 2*X.*T;
Z = 4*exp(2*XY);
surf(X,Y,Z)
where 'interesting' is the large value you mentioned.
I don't know if 'surf' will be upset having a hundred coincident pairs of X and Y all exactly equal to zero. If so, you could fudge the plot a tiny bit away from zero.
Roger Stafford
