Code covered by the BSD License  

Highlights from
Conic Plotter

image thumbnail

Conic Plotter

by

 

Plots conics given as implicit functions

final(varargin)
% Written by Sencer Corlu for Dr Pilant @ Texas A&M University Mathematics
% Department. This GUI is tested with Matlab machine in calclab, and works
% quite well on its own. On my personal computer, randi function gives
% error so if you, too have Matlab 7.5.0 or older, 
% this function will not work. Enjoy it!
function varargout = final(varargin)
global handleplots
% FINAL M-file for final.fig
%      FINAL, by itself, creates a new FINAL or raises the existing
%      singleton*.
%
%      H = FINAL returns the handle to a new FINAL or the handle to
%      the existing singleton*.
%
%      FINAL('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in FINAL.M with the given input arguments.
%
%      FINAL('Property','Value',...) creates a new FINAL or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before final_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to final_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 final

% Last Modified by GUIDE v2.5 05-Aug-2009 18:55:36

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
    'gui_Singleton',  gui_Singleton, ...
    'gui_OpeningFcn', @final_OpeningFcn, ...
    'gui_OutputFcn',  @final_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 final is made visible.
function final_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 final (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

% This sets up the initial plot - only do when we are invisible
% so window can get raised using final.
if strcmp(get(hObject,'Visible'),'off')
    plot(rand(3));
end
set(handles.edit4a, 'String', randi(10));
set(handles.edit4b, 'String', randi(10));
set(handles.edit4c, 'String', randi(10));

set(handles.edit4d, 'String', randi(10));
set(handles.edit4e, 'String', randi(10));
set(handles.edit4f, 'String', randi(10));

set(handles.edit4g, 'String', randi(10));
set(handles.edit4h, 'String', randi(10));
set(handles.edit4i, 'String', randi(10));


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


% --- Outputs from this function are returned to the command line.
function varargout = final_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;

% --- Executes on button press in pushbutton2d.
function pushbutton2d_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2d (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global handleplots
axes(handles.axes1);
cla;
eqn1 = get(handles.edit2a,'String');
eqn2 = get(handles.edit2b,'String');
eqn3 = get(handles.edit2c,'String');
hold on

if ~isempty(eqn1)
    handleplots.plot1 = ezplot(eqn1,[-10,10]);
end

if ~isempty(eqn2)
    handleplots.plot2 = ezplot(eqn2,[-10,10]);
end
if ~isempty(eqn3)
    handleplots.plot3 = ezplot(eqn3,[-10,10]);
end
hold off

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


% --------------------------------------------------------------------
function OpenMenuItem_Callback(hObject, eventdata, handles)
% hObject    handle to OpenMenuItem (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
file = uigetfile('*.fig');
if ~isequal(file, 0)
    open(file);
end

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

% --------------------------------------------------------------------
function CloseMenuItem_Callback(hObject, eventdata, handles)
global handleplots
% hObject    handle to CloseMenuItem (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
selection = questdlg(['Close ' get(handles.figure1,'Name') '?'],...
    ['Close ' get(handles.figure1,'Name') '...'],...
    'Yes','No','Yes');
if strcmp(selection,'No')
    return;
end


% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (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 popupmenu1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu1


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

% Hint: popupmenu 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

set(hObject, 'String', {'plot(rand(5))', 'plot(sin(1:0.01:25))', 'bar(1:.5:10)', 'plot(membrane)', 'surf(peaks)'});



function edit2a_Callback(hObject, eventdata, handles)
% hObject    handle to edit2a (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 edit2a as text
%        str2double(get(hObject,'String')) returns contents of edit2a as a double


% --- Executes during object creation, after setting all properties.
function edit2a_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2a (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 edit2b_Callback(hObject, eventdata, handles)
% hObject    handle to edit2b (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 edit2b as text
%        str2double(get(hObject,'String')) returns contents of edit2b as a double


% --- Executes during object creation, after setting all properties.
function edit2b_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2b (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 edit2c_Callback(hObject, eventdata, handles)
% hObject    handle to edit2c (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 edit2c as text
%        str2double(get(hObject,'String')) returns contents of edit2c as a double


% --- Executes during object creation, after setting all properties.
function edit2c_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2c (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 pushbutton2a.
function pushbutton2a_Callback(hObject, eventdata, handles)
global handleplots
% hObject    handle to pushbutton2a (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
delete(handleplots.plot1);


% --- Executes on button press in pushbutton2b.
function pushbutton2b_Callback(hObject, eventdata, handles)
global handleplots
% hObject    handle to pushbutton2b (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
delete(handleplots.plot2);

% --- Executes on selection change in listbox3a.
function listbox3a_Callback(hObject, eventdata, handles)
global answer
answer(1) = get(hObject,'Value');

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


% --- Executes during object creation, after setting all properties.
function listbox3a_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox3a (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 pushbutton2c.
function pushbutton2c_Callback(hObject, eventdata, handles)
global handleplots
% hObject    handle to pushbutton2c (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
delete(handleplots.plot3);

% --- Executes on selection change in listbox3b.
function listbox3b_Callback(hObject, eventdata, handles)
global answer
answer(2) = get(hObject,'Value');


% --- Executes during object creation, after setting all properties.
function listbox3b_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox3b (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 listbox3c.
function listbox3c_Callback(hObject, eventdata, handles)
global answer
answer(3) = get(hObject,'Value');


% --- Executes during object creation, after setting all properties.
function listbox3c_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox3c (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 pushbutton3c.
function pushbutton3c_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3c (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


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



function edit4a_Callback(hObject, eventdata, handles)
% hObject    handle to edit4a (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 edit4a as text
%        str2double(get(hObject,'String')) returns contents of edit4a as a double


% --- Executes during object creation, after setting all properties.
function edit4a_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4a (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 edit4b_Callback(hObject, eventdata, handles)
% hObject    handle to edit4b (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 edit4b as text
%        str2double(get(hObject,'String')) returns contents of edit4b as a double


% --- Executes during object creation, after setting all properties.
function edit4b_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4b (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 edit4c_Callback(hObject, eventdata, handles)
% hObject    handle to edit4c (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 edit4c as text
%        str2double(get(hObject,'String')) returns contents of edit4c as a double


% --- Executes during object creation, after setting all properties.
function edit4c_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4c (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 edit4d_Callback(hObject, eventdata, handles)
% hObject    handle to edit4d (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 edit4d as text
%        str2double(get(hObject,'String')) returns contents of edit4d as a double


% --- Executes during object creation, after setting all properties.
function edit4d_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4d (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 edit4e_Callback(hObject, eventdata, handles)
% hObject    handle to edit4e (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 edit4e as text
%        str2double(get(hObject,'String')) returns contents of edit4e as a double


% --- Executes during object creation, after setting all properties.
function edit4e_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4e (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 edit4f_Callback(hObject, eventdata, handles)
% hObject    handle to edit4f (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 edit4f as text
%        str2double(get(hObject,'String')) returns contents of edit4f as a double


% --- Executes during object creation, after setting all properties.
function edit4f_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4f (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 edit4g_Callback(hObject, eventdata, handles)
% hObject    handle to edit4g (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 edit4g as text
%        str2double(get(hObject,'String')) returns contents of edit4g as a double


% --- Executes during object creation, after setting all properties.
function edit4g_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4g (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 edit4h_Callback(hObject, eventdata, handles)
% hObject    handle to edit4h (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 edit4h as text
%        str2double(get(hObject,'String')) returns contents of edit4h as a double


% --- Executes during object creation, after setting all properties.
function edit4h_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4h (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 edit4i_Callback(hObject, eventdata, handles)
% hObject    handle to edit4i (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 edit4i as text
%        str2double(get(hObject,'String')) returns contents of edit4i as a double


% --- Executes during object creation, after setting all properties.
function edit4i_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4i (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 pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles)

set(handles.edit4a, 'String', randi(10));
set(handles.edit4b, 'String', randi(10));
set(handles.edit4c, 'String', randi(10));

set(handles.edit4d, 'String', randi(10));
set(handles.edit4e, 'String', randi(10));
set(handles.edit4f, 'String', randi(10));

set(handles.edit4g, 'String', randi(10));
set(handles.edit4h, 'String', randi(10));
set(handles.edit4i, 'String', randi(10));


% --- Executes on button press in pushbutton13.
function pushbutton13_Callback(hObject, eventdata, handles)
global answer
%compute
A = str2num(get(handles.edit4a, 'String'));
B = str2num(get(handles.edit4b, 'String'));
C = str2num(get(handles.edit4c, 'String'));
res1 = B^2 - 4*A*C;
if res1<0
     if (A == C) & (B == 0)
        type1 = 4;  %Circle
    else
        type1 = 1;  %ellipse
     end   
elseif res1 == 0
    type1 = 2; %parabola;
elseif res1 > 0
    type1 = 3; %hyperbola 
else
        type1=5;
end
    

A = str2num(get(handles.edit4d, 'String'));
B = str2num(get(handles.edit4e, 'String'));
C = str2num(get(handles.edit4f, 'String'));
res2 = B^2 - 4*A*C;
if res2<0
     if (A == C) & (B == 0)
        type2 = 4;  %Circle
    else
        type2 = 1;  %ellipse
     end   
elseif res2 == 0
    type2 = 2; %parabola;
elseif res2 > 0
    type2 = 3; %hyperbola 
else
        type2=5;
end

A = str2num(get(handles.edit4g, 'String'));
B = str2num(get(handles.edit4h, 'String'));
C = str2num(get(handles.edit4i, 'String'));
res3 = B^2 - 4*A*C;
if res3<0
     if (A == C) & (B == 0)
        type3 = 4;  %Circle
    else
        type3 = 1;  %ellipse
     end   
elseif res3 == 0
    type3 = 2; %parabola;
elseif res3 > 0
    type3 = 3; %hyperbola 
else
        type3=5;
end

if length([type1 type2 type3]) ~=3
    set(handles.text35, 'String', 'Choose Answer')
else
mark_choices = (answer ~= [type1 type2 type3])+1;
alist = [{'True'} {'False'}];
set(handles.text35, 'String', 'Results')
set(handles.text5b, 'String', ['A'; alist(mark_choices(1))]);
set(handles.text5c, 'String', ['B'; alist(mark_choices(2))]);
set(handles.text5d, 'String', ['C'; alist(mark_choices(3))]);
end

Contact us