Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Can someone help us with choosing the best syntax and nomenclature for this code?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I have this code we are trying to run to create vectors from n closest points. However, it seems to be getting too complicated. Can someone help us to have a cleaner, more efficient code given the attched file (fpep.mat)? Below is the current code. Thanks in advance for your help.
close all;
clearvars;
% load('F_points.mat');
load('fpep.mat');
n = 10;
for pt = 1 : 953
dist = sqrt((fpep(:,7)-fpep(pt,7)).^2 + (fpep(:,8)-fpep(pt,8)).^2);
[~, ascendIdx] = sort(dist); % Not really sure what this does or why there is a ~ used here. Can someone explain this?
xyNearest(pt,:,:) = fpep(ascendIdx(1:n),7:8);
adirector_x(pt,:,:) = ([fpep(ascendIdx(1:n),1) - xyNearest(pt,:,1)]);
adirector_y(pt,:,:) = ([fpep(ascendIdx(1:n),2) - xyNearest(pt,:,2)]);
bdirector_x(pt,:,:) = ([fpep(ascendIdx(1:n),3) - xyNearest(pt,:,1)]);
bdirector_y(pt,:,:) = ([fpep(ascendIdx(1:n),4) - xyNearest(pt,:,2)]);
cdirector_x(pt,:,:) = ([fpep(ascendIdx(1:n),5) - xyNearest(pt,:,1)]);
cdirector_y(pt,:,:) = ([fpep(ascendIdx(1:n),6) - xyNearest(pt,:,2)]);
ascendIdx(ascendIdx==pt) = []; %remove the source point. Not sure why the open brackets are used here. Can someone explain this?
end
chordx = ([xyNearest(:,:,1) - fpep(:,7)]);
chordy = ([xyNearest(:,:,2) - fpep(:,8)]);
chord = sqrt((chordx).^2 + (chordy).^2);
6 comentarios
Respuestas (0)
La pregunta está cerrada.
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!