title: Matlab: Color Coding a 3D Plot
body: <p>I've been trying to look around online for something I want but I'm not having much luck so I thought I would just ask on here. </p>
  
  <p>Is it possible to pinpoint in a different color and show the point on the graph where there are intersections between the two plots? </p>
  
  <p>Thanks for any help you can give.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>file1 = fopen('C:\Program Files (x86)\Notepad++\avatar1.txt'); % open text file
  file2 = fopen('C:\Program Files (x86)\Notepad++\avatar2.txt'); % open text file
  file3 = fopen('C:\Program Files (x86)\Notepad++\avatar3.txt'); % open text file
  
  tline1 = fgetl(file1); % read line by line and remove new line characters
  tline2 = fgetl(file2); % read line by line and remove new line characters
  tline3 = fgetl(file3); % read line by line and remove new line characters
  
  % declare empty arrays
  CX1 = [];
  CY1 = [];
  CZ1 = [];
  
  CX2 = [];
  CY2 = [];
  CZ2 = [];
  
  CX3 = [];
  CY3 = [];
  CZ3 = [];
  
  
  while ischar(tline1) % true if tline is a character array
      temp = cell2mat(textscan(tline1, '&lt;%n,%n,%n&gt;'));
  
      % convert all the cell fields to a matrix
      CX1 = vertcat(CX1, temp(1));
      CY1 = vertcat(CY1, temp(2));
      CZ1 = vertcat(CZ1, temp(3));
  
      tline1 = fgetl(file1);
  end
  
  while ischar(tline2) % true if tline is a character array
      temp = cell2mat(textscan(tline2, '&lt;%n,%n,%n&gt;'));
  
      % convert all the cell fields to a matrix
      CX2 = vertcat(CX2, temp(1));
      CY2 = vertcat(CY2, temp(2));
      CZ2 = vertcat(CZ2, temp(3));
  
      tline2 = fgetl(file2);
  end
  
  while ischar(tline3) % true if tline is a character array
      temp = cell2mat(textscan(tline3, '&lt;%n,%n,%n&gt;'));
  
      % convert all the cell fields to a matrix
      CX3 = vertcat(CX3, temp(1));
      CY3 = vertcat(CY3, temp(2));
      CZ3 = vertcat(CZ3, temp(3));
  
      tline3 = fgetl(file3);
  end
  
  fclose(file1); % close the file
  fclose(file2); % close the file
  fclose(file3); % close the file
  
  plot3(CX1, CY1, CZ1) % plot the data and label the axises
  plot3(CX2, CY2, CZ2)
  plot3(CX3, CY3, CZ3)
  xlabel('x')
  ylabel('y')
  zlabel('z') 
  grid on
  axis square
  rotate3d on; % activate interactive mouse rotation
  </code></pre>