randomly sample a pair of values in a double
1 次查看(过去 30 天)
显示 更早的评论
I have two doubles of the type coord_iso=65x2 double and coord_ce=65x2 double (they are all pairs of geographic coordinates).
I need to RANDOM sample one of the coordinate pairs inside the coord_iso. how can I do?
then with this randomly sampled pair and the first pair of coord_ce (row 1) I have to calculate the distance in km. in this case I was thinking of using distance and then the value/180*pi*6371.
you can help me?
0 个评论
采纳的回答
Star Strider
2022-12-8
‘I need to RANDOM sample one of the coordinate pairs inside the coord_iso. how can I do?’
One option —
RandomRow = randi(size(coord_iso,1));
RandomResult = coord_iso(RandomRow,:)
These can be combined into one assignment —
RandomResult = coord_iso(randi(size(coord_iso,1)),:)
Example —
coord_iso = [ 91.36 14.46
91.38 14.50
91.42 14.51
91.46 14.51
91.49 14.47];
RandomResult = coord_iso(randi(size(coord_iso,1)),:)
.
0 个评论
更多回答(1 个)
Jan
2022-12-8
You want a random integer in the range [1, 65] as index? randi([1, 65])
I have no idea, what "distance and then the value/180*pi*6371" means.
2 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Random Number Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!