How can I convert 100 X Y and Z coordinates generated randomly in the form of a 100x100x100 matrix

조회 수: 2 (최근 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
Tamoor Shafique
Tamoor Shafique 2020년 10월 30일
  1. XR(i), YR(i), and ZR(i) are 100 random coordinates each. for 100 iterations of i. so each iteration gives a 3d point.
  2. yes the 100 points should on the 100 should be 1 that would do.
Matt J
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
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
Name Size Bytes Class Attributes A 100x100x100 1000000 logical
nnz(A)
ans = 100
  댓글 수: 2
Tamoor Shafique
Tamoor Shafique 2020년 10월 30일
I need 100x100x100 array of actual coordinates please for example (24,58,19) if thats possible. I know this might feel strange but this is the case
Tamoor Shafique
Tamoor Shafique 2020년 10월 30일
so instead of ones at the corresponding location i wish to display the actual value of point

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by