Also consider using for loops to eliminate the need for storage of 
intermediates.  For loops are much faster in Julia than in Matlab.

On Tuesday, November 25, 2014 2:26:39 PM UTC-6, Peter Simon wrote:
>
> You can find examples of both meshgrid and ndgrid implemented in 
> https://github.com/JuliaLang/julia/blob/master/examples/ndgrid.jl .
> However, you will find that generally meshgrid is not needed, as similar 
> functionality can be accomplished by broadcasting 
> <http://docs.julialang.org/en/release-0.3/manual/arrays/?highlight=broadcast#broadcasting>
>  or 
> by use of comprehensions 
> <http://docs.julialang.org/en/release-0.3/manual/arrays/?highlight=broadcast#comprehensions>
> .
>
> --Peter
>
> On Tuesday, November 25, 2014 11:39:57 AM UTC-8, Pileas wrote:
>>
>> Hi brothers,
>>
>> I am practicing a little bit in Julia now, and I want to see how meshgrid 
>> (if there is any) works. I found an example in Matlab (for I find it easier 
>> to cope with and make it Julia compatible), but I don't know how to do the 
>> meshgrid.
>>
>> Here is the example:
>>
>> --------------------------------------------------
>> col = 20;
>> m = 400;
>> cx = -.6;
>> cy = 0;
>> l = 1.5;
>> x = linspace(cx-l,cx + l,m);
>> y = linspace(cy-l,cy + l,m);
>> (X,Y) = ndgrid(x,y);
>> Z = zeros(m);
>> C = X + i * Y;
>>
>> for k = 1:col;
>>     Z = Z.^2+C;
>>     W = exp(-abs(Z));
>> end
>>
>> colormap copper(256);
>> pcolor(W);
>> shading flat;
>> axis(’square’,’equal’,’off’);
>> -----------------------------------------
>>
>> I would really appreciate if someone can give a working example in Julia 
>> of the aforementioned.
>>
>>
>> Best ...
>>
>>

Reply via email to