Creating a matrix from vectors to have unique combinations

2 ビュー (過去 30 日間)
modelhelp
modelhelp 2016 年 5 月 11 日
回答済み: Azzi Abdelmalek 2016 年 5 月 11 日
I am trying to populate a nx3 matrix such that every row is a unique combination. Here are my variables.
lat = (-25:0.1:-16);
lon = (-76:0.1:-64);
dep= [0:1:300];
What I am trying to get is a matrix that with length(lat)*length(lon)*length(dep) rows and 3 columns and should consist of every possible combination of lat, long and depth. For example, for a specific lat/long combination there should be 300 values. I feel like this should be very simple but I am not able to figure it out.

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 5 月 11 日
lat = (-25:0.1:-16)
lon = (-76:0.1:-64)
dep= [0:1:300]
[x,y,z]=meshgrid(lat,lon,dep);
out=[x(:) y(:) z(:)];

その他の回答 (0 件)

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by