简体   繁体   中英

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!

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:

在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM