I should say all the rest entries in 100x100x100 matrix should result (0,0,0) but only the 100 points should say(XR(i), YR(i), ZR(i)) so the actual coordinate values
How can I convert 100 X Y and Z coordinates generated randomly in the form of a 100x100x100 matrix
1 次查看(过去 30 天)
显示 更早的评论
close all
clear all
n = 100;
xm = 100;
ym = 100;
zm = 100;
x = 0;
y = 0;
z = 0;
for i=1:1:n
S(i).xd=rand(1,1)*xm;
XR(i)=S(i).xd;
S(i).yd=rand(1,1)*ym;
YR(i)=S(i).yd;
S(i).zd=rand(1,1)*zm;
ZR(i)=S(i).zd;
end
this gives me 100 random x, y and z-axis. I can plot the points but how can i group them as a 3D matrix of 100x100x100 such that matrix entries are (XR(i), YR(i), ZR(i))
4 个评论
Matt J
2020-10-30
yes the 100 points should on the 100 should be 1 that would do.
But that is what I gave you below.
采纳的回答
Matt J
2020-10-30
If you mean you want a 100x100x100 binary array A with one hundred randomly located entries where A(i,jk)=1, then
A=false(100,100,100);
A( randperm(numel(A),100) )=1;
whos A
nnz(A)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!