How to determine and plot a marker where points intersect?
Afficher commentaires plus anciens
I have two sets of data points: x,y,z & x2,y2,z2. I want to determine at which points the data points intersect and at those points I want to plot a marker. I tried creating two matrices of the two data sets but then I was not sure how to determine from there which rows are equal in the two matrices. My code is below...
clc;
clear variables;
close all;
n = input('number of revolutions ');
r = input('radius ');
%l = input('length ');
a = input('angle with respect to the upwards horizontal in degrees ');
w = input('number of wires ');
h=(2*n*pi*r)/tand(90-a); %height of stent determined by other inputs
%n = (l*tand(90-a))/(2*pi*r); %number of turns
%a=90-(atand((2*n*pi*r)/l));
if mod(w,2) ==0 %number of wires is even
else
fprintf('ERROR:number of wires must be even'); %stops code if wire number is odd
return
end
if mod(n,1) ==0 %number of revolutions is whole number
else
fprintf('ERROR:number of revolutions must be whole number');
return
end
e = (2*pi)/(w/2); %theta (spacing between where each wire starts)
for i=1:w/2
t{i} = (i-1)*e:pi/w:(n*2*pi)+e*(i-1); %t value for CCW helices
x{i} = r*sin(t{i});
y{i} = r*cos(t{i});
z{i} = (h/(n*2*pi))*t{1};
plot3(x{i},y{i},z{i}, '.','MarkerSize',25,'MarkerFaceColor','yellow','MarkerEdgeColor','yellow') %plot CCW helices
hold on;
end
hold on;
for i=1:w/2
t2{i} = (n*2*pi)+(e*(i-1)):-pi/w:(i-1)*e; %t value for CW helices
x2{i} = r*sin(t2{i});
y2{i} = r*cos(t2{i});
z2{i} =(h/(n*2*pi))*t{1};
plot3(x2{i},y2{i},z2{i},'.','MarkerSize',25,'MarkerFaceColor','black','MarkerEdgeColor','black') %plot CW helices
hold on;
end
hold on;
L=cell2mat([x y z])' ;
K=cell2mat([x2 y2 z2])';
Réponses (0)
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!