No BSD License  

Highlights from
2d and 3d GUI example plot with names and classes

image thumbnail
from 2d and 3d GUI example plot with names and classes by Giorgio kimiko
A GUIDe for routine plots with classes and names with custom colors and symbols that can remove poin

Plot3drem(varargin)
function varargout = Plot3drem(varargin)
%    Contains Code of removepoint made by Jean-Luc Dellis you can find at
%    http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=11213
%
%      PLOT3DREM M-file for Plot3drem.fig
%      PLOT3DREM, by itself, creates a new PLOT3DREM or raises the existing
%      singleton*.
%
%      H = PLOT3DREM returns the handle to a new PLOT3DREM or the handle to
%      the existing singleton*.
%
%      PLOT3DREM('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in PLOT3DREM.M with the given input arguments.
%
%      PLOT3DREM('Property','Value',...) creates a new PLOT3DREM or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Plot3drem_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Plot3drem_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Plot3drem

% Last Modified by GUIDE v2.5 15-Sep-2006 15:09:07

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Plot3drem_OpeningFcn, ...
                   'gui_OutputFcn',  @Plot3drem_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before Plot3drem is made visible.
function Plot3drem_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Plot3drem (see VARARGIN)

% Choose default command line output for Plot3drem
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Plot3drem wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = Plot3drem_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;



vars = evalin('base','who');
set(handles.MyMatrix,'String',vars)
set(handles.MyClasses,'String',vars)
set(handles.MyNames,'String',vars)

% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

vars = evalin('base','who');
set(handles.MyMatrix,'String',vars)
set(handles.MyClasses,'String',vars)
set(handles.MyNames,'String',vars)

% --- Executes on button press in pushbutton2.
function Plot_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

Color=['r' 'b' 'g' 'k' 'm' 'c' 'y' 'r' 'b' 'g' 'k' 'm' 'c' 'y'];
v1=str2double(get(handles.XAxis,'String'));
v2=str2double(get(handles.YAxis,'String'));
v3=str2double(get(handles.YAxis,'String'));
hl=get(handles.XLabel,'String');
vl=get(handles.YLabel,'String');
zl=get(handles.ZLabel,'String');
tt=get(handles.Title,'String');
esp1=str2double(get(handles.XExpansion,'String'));
esp2=str2double(get(handles.YExpansion,'String'));
esp3=str2double(get(handles.ZExpansion,'String'));

listMyMatrix = get(handles.MyMatrix,'String');
indexMyMatrix = get(handles.MyMatrix,'Value');
MyMatrix = evalin('base',listMyMatrix{indexMyMatrix(1)});

%if (get(handles.ClassesCheck,'Value') == get(handles.ClassesCheck,'Max')) 
figure
for i=1:size(MyMatrix,1);
    h=plot3 (MyMatrix(:,v1),MyMatrix(:,v2),MyMatrix(:,v3),'o');
    grid on
    %   set(h,'color',Color(classvariable(i)))
end
 
 set(h,'markersize',10);
 set(gca,'XLim',[(min(MyMatrix(:,v1))-(0.01*esp1*(max(MyMatrix(:,v1))-min(MyMatrix(:,v1))))) (max(MyMatrix(:,v1))+(0.01*esp1*(max(MyMatrix(:,v1))-min(MyMatrix(:,v1)))))]);
 set(gca,'YLim',[(min(MyMatrix(:,v2))-(0.01*esp2*(max(MyMatrix(:,v2))-min(MyMatrix(:,v2))))) (max(MyMatrix(:,v2))+(0.01*esp2*(max(MyMatrix(:,v2))-min(MyMatrix(:,v2)))))]);
 set(gca,'ZLim',[(min(MyMatrix(:,v3))-(0.01*esp3*(max(MyMatrix(:,v3))-min(MyMatrix(:,v3))))) (max(MyMatrix(:,v3))+(0.01*esp3*(max(MyMatrix(:,v3))-min(MyMatrix(:,v3)))))]);
 set(gca,'xlabel',text(0,0,hl));
 set(gca,'ylabel',text(0,0,vl));
 set(gca,'zlabel',text(0,0,zl));
 title (tt)

[row,columns]=size(MyMatrix);

  if  get(handles.ClassesCheck,'Value') == get(handles.ClassesCheck,'min') & get(handles.NamesCheck,'Value') == get(handles.NamesCheck,'min')
      for a=1:row
	  text(MyMatrix(a,v1),MyMatrix(a,v2),MyMatrix(a,v3),int2str(a))
      end
  elseif  get(handles.ClassesCheck,'Value') == get(handles.ClassesCheck,'Max') & get(handles.NamesCheck,'Value') == get(handles.NamesCheck,'min')
    
     listMyClasses = get(handles.MyClasses,'String');
     indexMyClasses = get(handles.MyClasses,'Value');
     MyClasses = evalin('base',listMyClasses{indexMyClasses(1)});

      for k=1:max(MyClasses)
	  ix=find(MyClasses==k);
      for j=1:size(ix,1)
      text(MyMatrix(ix,v1),MyMatrix(ix,v2),MyMatrix(ix,v3),int2str(MyClasses(ix(j))),'Color',Color(k))
      end
      end

  elseif  get(handles.ClassesCheck,'Value') == get(handles.ClassesCheck,'Max') & get(handles.NamesCheck,'Value') == get(handles.NamesCheck,'Max') 
      
     listMyClasses = get(handles.MyClasses,'String');
     indexMyClasses = get(handles.MyClasses,'Value');
     MyClasses = evalin('base',listMyClasses{indexMyClasses(1)})
  
     listMyNames = get(handles.MyNames,'String');
     indexMyNames = get(handles.MyNames,'Value');
     MyNames = evalin('base',listMyNames{indexMyNames(1)});
  
    for k=1:max(MyClasses)
 	   ix=find(MyClasses==k);
 	   text(MyMatrix(ix,v1),MyMatrix(ix,v2),MyMatrix(ix,v3),(MyNames(ix,:)),'Color',Color(k))
 	 end
  
  
  else
      
       listMyNames = get(handles.MyNames,'String');
       indexMyNames = get(handles.MyNames,'Value');
       MyNames = evalin('base',listMyNames{indexMyNames(1)});
       sizeMyNames = size(MyNames)
       c= ones(sizeMyNames)
       MyClasses=c(:,1)
     for k=1:max(MyClasses)
 	   ix=find(MyClasses==k);
 	   text(MyMatrix(ix,v1),MyMatrix(ix,v2),MyMatrix(ix,v3),(MyNames(ix,:)),'Color',Color(k))
 	 end
  end
  
if get(handles.EqualBox,'Value') == get(handles.EqualBox,'Max')
      axis('equal')
end
  
function XAxis_Callback(hObject, eventdata, handles)
% hObject    handle to XAxis (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of XAxis as text
%        str2double(get(hObject,'String')) returns contents of XAxis as a double


% --- Executes during object creation, after setting all properties.
function XAxis_CreateFcn(hObject, eventdata, handles)
% hObject    handle to XAxis (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function Yaxis_Callback(hObject, eventdata, handles)
% hObject    handle to Yaxis (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Yaxis as text
%        str2double(get(hObject,'String')) returns contents of Yaxis as a double


% --- Executes during object creation, after setting all properties.
function Yaxis_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Yaxis (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function Xlabel_Callback(hObject, eventdata, handles)
% hObject    handle to Xlabel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Xlabel as text
%        str2double(get(hObject,'String')) returns contents of Xlabel as a double


% --- Executes during object creation, after setting all properties.
function Xlabel_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Xlabel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function YLable_Callback(hObject, eventdata, handles)
% hObject    handle to YLable (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of YLable as text
%        str2double(get(hObject,'String')) returns contents of YLable as a double


% --- Executes during object creation, after setting all properties.
function YLable_CreateFcn(hObject, eventdata, handles)
% hObject    handle to YLable (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function Title_Callback(hObject, eventdata, handles)
% hObject    handle to Title (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Title as text
%        str2double(get(hObject,'String')) returns contents of Title as a double


% --- Executes during object creation, after setting all properties.
function Title_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Title (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in EqualBox.
function EqualBox_Callback(hObject, eventdata, handles)
% hObject    handle to EqualBox (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of EqualBox


% --- Executes on selection change in MyMatrix.
function MyMatrix_Callback(hObject, eventdata, handles)
% hObject    handle to MyMatrix (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns MyMatrix contents as cell array
%        contents{get(hObject,'Value')} returns selected item from MyMatrix


% --- Executes during object creation, after setting all properties.
function MyMatrix_CreateFcn(hObject, eventdata, handles)
% hObject    handle to MyMatrix (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on selection change in MyClasses.
function MyClasses_Callback(hObject, eventdata, handles)
% hObject    handle to MyClasses (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns MyClasses contents as cell array
%        contents{get(hObject,'Value')} returns selected item from MyClasses


% --- Executes during object creation, after setting all properties.
function MyClasses_CreateFcn(hObject, eventdata, handles)
% hObject    handle to MyClasses (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on selection change in listbox3.
function listbox3_Callback(hObject, eventdata, handles)
% hObject    handle to listbox3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns listbox3 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from listbox3


% --- Executes during object creation, after setting all properties.
function listbox3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in ClassesCheck.
function ClassesCheck_Callback(hObject, eventdata, handles)
% hObject    handle to ClassesCheck (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of ClassesCheck
if (get(handles.ClassesCheck,'Value') == get(handles.ClassesCheck,'Max'))
    % then checkbox is checked-take approriate action
     set(handles.MyClasses,'Enable', 'on')
   
else
     set(handles.MyClasses,'Enable', 'off')
        
end

% --- Executes on button press in NamesCheck.
function NamesCheck_Callback(hObject, eventdata, handles)

if (get(handles.NamesCheck,'Value') == get(handles.NamesCheck,'Max'))
    % then checkbox is checked-take approriate action
     set(handles.MyNames,'Enable', 'on')
   
else
     set(handles.MyNames,'Enable', 'off')
        
end
% hObject    handle to NamesCheck (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of NamesCheck





function YAxis_Callback(hObject, eventdata, handles)
% hObject    handle to YAxis (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of YAxis as text
%        str2double(get(hObject,'String')) returns contents of YAxis as a double


% --- Executes during object creation, after setting all properties.
function YAxis_CreateFcn(hObject, eventdata, handles)
% hObject    handle to YAxis (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function XLabel_Callback(hObject, eventdata, handles)
% hObject    handle to XLabel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of XLabel as text
%        str2double(get(hObject,'String')) returns contents of XLabel as a double


% --- Executes during object creation, after setting all properties.
function XLabel_CreateFcn(hObject, eventdata, handles)
% hObject    handle to XLabel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function XExpansion_Callback(hObject, eventdata, handles)
% hObject    handle to XExpansion (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of XExpansion as text
%        str2double(get(hObject,'String')) returns contents of XExpansion as a double


% --- Executes during object creation, after setting all properties.
function XExpansion_CreateFcn(hObject, eventdata, handles)
% hObject    handle to XExpansion (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end





function YExpansion_Callback(hObject, eventdata, handles)
% hObject    handle to YExpansion (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of YExpansion as text
%        str2double(get(hObject,'String')) returns contents of YExpansion as a double


% --- Executes during object creation, after setting all properties.
function YExpansion_CreateFcn(hObject, eventdata, handles)
% hObject    handle to YExpansion (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end




% --- Executes on button press in Scatter.
function Scatter_Callback(hObject, eventdata, handles)
% hObject    handle to Scatter (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


v1=str2double(get(handles.XAxis,'String'))
v2=str2double(get(handles.YAxis,'String'))
v3=str2double(get(handles.ZAxis,'String'))
hl=get(handles.XLabel,'String')
vl=get(handles.YLabel,'String')
zl=get(handles.ZLabel,'String')
tt=get(handles.Title,'String')
esp1=str2double(get(handles.XExpansion,'String'))
esp2=str2double(get(handles.YExpansion,'String'))
esp3=str2double(get(handles.YExpansion,'String'))
listMyMatrix = get(handles.MyMatrix,'String');
indexMyMatrix = get(handles.MyMatrix,'Value');
MyMatrix = evalin('base',listMyMatrix{indexMyMatrix(1)});

listMyNames = get(handles.MyNames,'String');
indexMyNames = get(handles.MyNames,'Value');
MyNames = evalin('base',listMyNames{indexMyNames(1)});

figure
h=scatter3(MyMatrix(:,v1),MyMatrix(:,v2),MyMatrix(:,v3));
  grid on

set(gca,'XLim',[(min(MyMatrix(:,v1))-(0.01*esp1*(max(MyMatrix(:,v1))-min(MyMatrix(:,v1))))) (max(MyMatrix(:,v1))+(0.01*esp1*(max(MyMatrix(:,v1))-min(MyMatrix(:,v1)))))]);
set(gca,'YLim',[(min(MyMatrix(:,v2))-(0.01*esp2*(max(MyMatrix(:,v2))-min(MyMatrix(:,v2))))) (max(MyMatrix(:,v2))+(0.01*esp2*(max(MyMatrix(:,v2))-min(MyMatrix(:,v2)))))]);
set(gca,'ZLim',[(min(MyMatrix(:,v3))-(0.01*esp3*(max(MyMatrix(:,v3))-min(MyMatrix(:,v3))))) (max(MyMatrix(:,v3))+(0.01*esp3*(max(MyMatrix(:,v3))-min(MyMatrix(:,v3)))))]);
set(gca,'xlabel',text(0,0,hl));
set(gca,'ylabel',text(0,0,vl));
set(gca,'zlabel',text(0,0,zl));
title (tt)

if get(handles.EqualBox,'Value') == get(handles.EqualBox,'Max')
     axis('equal')
end


function ZExpansion_Callback(hObject, eventdata, handles)
% hObject    handle to ZExpansion (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of ZExpansion as text
%        str2double(get(hObject,'String')) returns contents of ZExpansion as a double


% --- Executes during object creation, after setting all properties.
function ZExpansion_CreateFcn(hObject, eventdata, handles)
% hObject    handle to ZExpansion (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function ZLabel_Callback(hObject, eventdata, handles)
% hObject    handle to ZLabel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of ZLabel as text
%        str2double(get(hObject,'String')) returns contents of ZLabel as a double


% --- Executes during object creation, after setting all properties.
function ZLabel_CreateFcn(hObject, eventdata, handles)
% hObject    handle to ZLabel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function ZAxis_Callback(hObject, eventdata, handles)
% hObject    handle to ZAxis (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of ZAxis as text
%        str2double(get(hObject,'String')) returns contents of ZAxis as a double


% --- Executes during object creation, after setting all properties.
function ZAxis_CreateFcn(hObject, eventdata, handles)
% hObject    handle to ZAxis (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end




% --- Executes on button press in RemovePointsCheck.
function RemovePointsCheck_Callback(hObject, eventdata, handles)
% hObject    handle to RemovePointsCheck (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of RemovePointsCheck

if (get(handles.RemovePointsCheck,'Value') == get(handles.RemovePointsCheck,'Max'))
    % then checkbox is checked-take approriate action
    set(handles.Scatter,'Enable', 'off')
   else
    set(handles.Scatter,'Enable', 'on')
    
end




% --- Executes on button press in RemovePoints.
function RemovePoints_Callback(hObject, eventdata, handles)
% hObject    handle to RemovePoints (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

calls = get(handles.RemovePoints, 'userdata');
if isempty(calls);
  calls = 0; % first call
else
  calls = calls+1;
end
set(handles.RemovePoints, 'userdata', calls);

marks=['+','o','*','.','x','s','d','^','v','>','<','p','h',];
colo=['m','c','r','g','b','k'];
hl=findobj(gcf,'type','line');                              % get all line handles
set(0,'userdata',length(hl))
itag=0;
for i=length(hl):-1:1
    mar=get(hl(i),'marker');
    if isequal(mar,'none')
        im=ceil(rand(1,1)*length(marks));
        ic=ceil(rand(1,1)*length(colo));
        set(hl(i),'marker',marks(im),'color',colo(ic))      % set lines with markers if they have not
    end
    xdat=get(hl(i),'xdata');
    ydat=get(hl(i),'ydata');
    zdat=get(hl(i),'zdata');
    if isempty(zdat)
        zdat=zeros(size(xdat));
        set(hl(i),'zdata',zdat)                             % set lines with zeroed zdata if they have not
    end
    itag=itag+1;
    setappdata(hl(i),'tag',num2str(itag))                   % set lines with tag
    if isempty(getappdata(hl(i),'userdata'))
    setappdata(hl(i),'userdata',[xdat(:),ydat(:),zdat(:)])  % set userdata to initial data for the first time
    end
end
%---------------------------------------------%
                         
                                                            % when 2 arguments are required
hl=findobj(gcf,'type','line');                              % get all line handles
%hui=findobj(gcf,'tag','removepoint');
hln=get(0,'userdata');
if ~isequal(length(hl),hln) ;                                % a new line was plotted when remopoint was previouly
    removepoint                                             % running. So, run again to update
    set(gca,'xlimmode','auto','ylimmode','auto','zlimmode','auto')
end                        
                                                            
    dcm_obj = datacursormode(gcf);
    set(dcm_obj,'enable','on');
    infostruct = [];
while isempty(infostruct);                 
     pause(0.1);
    infostruct=getCursorInfo(dcm_obj);                    % get data_index + position + handle from the cursor
end
set(dcm_obj,'enable','off');
delete(findall(gca,'type','hggroup','marker','square'));     % delete datatip (handlevisibility off ==> findall)
fgx=get(gca,'xlim');fgy=get(gca,'ylim');fgz=get(gca,'zlim');% get limits of the current axe
target=infostruct.Target;                                   % handle of clicked line
xdat=get(target,'xdata');
ydat=get(target,'ydata');
zdat=get(target,'zdata');

A=getappdata(target,'userdata');                                       % retrieves original data, and
                                                            % identifies the index of the clicked point
i=(A(:,3)==zdat(infostruct.DataIndex) & A(:,2)==ydat(infostruct.DataIndex)& A(:,1)==xdat(infostruct.DataIndex));

A(i,:)=nan;                                                % deleted data is naned, and
setappdata(target,'userdata',A);                            % remaining index data are identified:
survyvingindex=find(~isnan(A(:,1)) & ~isnan(A(:,2)) & ~isnan(A(:,3)));

xdat(infostruct.DataIndex)=nan;                             % remove the coordinates, changing them in NAN
ydat(infostruct.DataIndex)=nan;
zdat(infostruct.DataIndex)=nan;
xdat = xdat(~isnan(xdat));                                  % NANs are removed from data
ydat = ydat(~isnan(ydat));
zdat = zdat(~isnan(zdat));


modifdata=[xdat(:),ydat(:),zdat(:)]; 
set(infostruct.Target,'xdata',modifdata(:,1));               % updates the line
set(infostruct.Target,'ydata',modifdata(:,2));
set(infostruct.Target,'zdata',modifdata(:,3));
set(gca,'xlim',fgx);set(gca,'ylim',fgy);set(gca,'zlim',fgz);% holds the limits
%---------------------------------------------%  

listMyMatrix = get(handles.MyMatrix,'String'); % read user data
indexMyMatrix = get(handles.MyMatrix,'Value');
MyMatrix = evalin('base',listMyMatrix{indexMyMatrix(1)});

listMyNames = get(handles.MyNames,'String');
indexMyNames = get(handles.MyNames,'Value');
MyNames = evalin('base',listMyNames{indexMyNames(1)});

listMyClasses = get(handles.MyClasses,'String');
indexMyClasses = get(handles.MyClasses,'Value');
MyClasses = evalin('base',listMyClasses{indexMyClasses(1)});


NewMatrix=MyMatrix(survyvingindex,:);
NewNames=MyNames(survyvingindex,:);
NewClasses=MyClasses(survyvingindex,:);

numCalls=num2str(calls);

assignin('base',['remaining_index',numCalls],survyvingindex);% put the modifyied data in the Matlab memory
assignin('base',['NewMatrix',numCalls],NewMatrix);% assign new matrix in Matlab base workspace
assignin('base',['NewNames',numCalls],NewNames);%
assignin('base',['NewClasses',numCalls],survyvingindex);%










Contact us at files@mathworks.com