how to store coordinate values xy[] for randomly generate point
5 次查看(过去 30 天)
显示 更早的评论
for i=1:NumOfNodes
S(i).xd=rand(1)*xm;
S(i).yd=rand(1)*ym;
end
from this given code I can store coordinate of randomly generate point in matrix format but
How could I store coordinate of randomly generate point xy=[3.7739 88.5168; ........]; like this format .
0 个评论
采纳的回答
更多回答(1 个)
Turlough Hughes
2020-5-15
The format you used (based on the code you provided) is a structure and the format you are looking for is an array. To generate an N by 2 array as you specified you can do the following:
N = 20;
xm = % some value
ym = % some value
xy = rand(N,2).*[xm ym];
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!