Using a for loop to determine the 3D distances between an array of points along a 2D plane and a single point in space.
Ältere Kommentare anzeigen
I need to apply this formula to each of the points along a 2D plane: Distance = sqrt(((x2-x1).^2)+((y2-y1).^2)+((z2-z1).^2))
x1, y1 and z1 will all remain constant as they are the single point in space. Currently, I have the 2D plane's x,y & z coordinates stored in a 3 dimensional array.
This is the code I have got so far.
c= 343; % speed of sound
Rsize = 3; % Size of the Reflector plane
p= 20; % No. of points in reflector plane
Spacing = Rsize/p;
Fmax= 2*p; %Highest Freq. used in predictions
fs= 48000; %Sample Rate
[X, Z]= meshgrid(0:Spacing:Rsize); %Defining Reflector Plane
Y= zeros(size(X, 1));
Rplane = cat(3, X, Y, Z);
Xs= 1.5; % Source Position
Ys= 3;
Zs= 1.5;
Xr= 1.5; %Receiver Position
Yr= 0.5:0.5:3;
Zr=1.5;
%%Plot locations of elements
%hold
%mesh(X, Y, Z);
%plot3(Xs,Ys,Zs,'*');
%plot3(Xr,Yr,Zr,'*');
%%Distance Calculations
SXdist = zeros(size(Rplane));
for i = numel(Rplane);
SXdist(i) = sqrt( )
Any help getting my head around this would be greatly appreciated!
1 Kommentar
Matt J
am 12 Aug. 2017
Where is x1,y1,z1?
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Phased Array Design and Analysis finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!