Beata
Beata

Reputation: 355

How can I create two matrices with meshgrid function in R?

I am beginer in R but I have experience in Matlab. In Matlab I could create two matrices with meshgrid function by the following way:

[lon, lat]=meshgrid(lon, lat) 

where lon and lat are vectors with length_lon=424 and length_lat=412. The resulted lon and lat martices are 424x412. How can I carry out this method in R? I would appreciate if you helped me!

Upvotes: 2

Views: 3923

Answers (1)

Dan
Dan

Reputation: 45741

It looks like there are R implementations of meshgrid available: http://www.inside-r.org/packages/cran/pracma/docs/meshgrid or http://artax.karlin.mff.cuni.cz/r-help/library/AtmRay/html/meshgrid.html

Or according to this R for MATLAB users article:

enter image description here

I think if you want an idiomatic R solution, you should explain why you want to use meshgrid...

Upvotes: 3

Related Questions