function varargout = transform(varargin) %TRANSFORM M-file for transform.fig % TRANSFORM, by itself, creates a new TRANSFORM or raises the existing % singleton*. % % H = TRANSFORM returns the handle to a new TRANSFORM or the handle to % the existing singleton*. % % TRANSFORM('Property','Value',...) creates a new TRANSFORM using the % given property value pairs. Unrecognized properties are passed via % varargin to transform_OpeningFcn. This calling syntax produces a % warning when there is an existing singleton*. % % TRANSFORM('CALLBACK') and TRANSFORM('CALLBACK',hObject,...) call the % local function named CALLBACK in TRANSFORM.M with the given input % arguments. % % *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 transform % Last Modified by GUIDE v2.5 01-Aug-2011 12:18:02 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @transform_OpeningFcn, ... 'gui_OutputFcn', @transform_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 transform is made visible. function transform_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 unrecognized PropertyName/PropertyValue pairs from the % command line (see VARARGIN) % Choose default command line output for transform handles.output = hObject; % Update handles structure guidata(hObject, handles); % --- Outputs from this function are returned to the command line. function varargout = transform_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 pushButtonSelect. function pushButtonSelect_Callback(hObject, eventdata, handles) % hObject handle to pushButtonSelect (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) graphfunction(hObject, eventdata, handles); % --- Executes on selection change in functionmenu. function functionmenu_Callback(hObject, eventdata, handles) % hObject handle to functionmenu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) v=get(hObject,'value'); if v==2 func='a*(b*x+c)+d'; elseif v==3 func='a*abs(b*x+c)+d'; elseif v==4 func='a*(b*x+c)^2+d'; elseif v==5 func='a*(b*x+c)^3+d'; elseif v==6 func='a*sqrt(b*x+c)+d'; elseif v==7 func='a*sin(b*x+c)+d'; elseif v==8 func='a*cos(b*x+c)+d'; elseif v==9 func='a*tan(b*x+c)+d'; else func='Begin by choosing a function'; end set(handles.display,'String',func); % --- Executes during object creation, after setting all properties. function functionmenu_CreateFcn(hObject, eventdata, handles) % hObject handle to functionmenu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on slider movement. function sliderD_Callback(hObject, eventdata, handles) % hObject handle to sliderd (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,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider %graphFunction(); slider_value = get(hObject,'Value'); d=floor(10*slider_value); set(handles.textd,'String',d); graphfunction(hObject, eventdata, handles); % --- Executes during object creation, after setting all properties. function sliderD_CreateFcn(hObject, eventdata, handles) % hObject handle to sliderd (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: slider controls usually have a light gray background. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end % --- Executes on slider movement. function sliderB_Callback(hObject, eventdata, handles) % hObject handle to sliderB (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,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider slider_value = get(hObject,'Value'); b=floor(10*slider_value); set(handles.textb,'String',b); graphfunction(hObject, eventdata, handles); % --- Executes during object creation, after setting all properties. function sliderB_CreateFcn(hObject, eventdata, handles) % hObject handle to sliderB (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: slider controls usually have a light gray background. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end % --- Executes on slider movement. function sliderC_Callback(hObject, eventdata, handles) % hObject handle to sliderC (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,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider slider_value = get(hObject,'Value'); c=floor(10*slider_value); set(handles.textc,'String',c); graphfunction(hObject, eventdata, handles); % --- Executes during object creation, after setting all properties. function sliderC_CreateFcn(hObject, eventdata, handles) % hObject handle to sliderC (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: slider controls usually have a light gray background. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end % --- Executes on slider movement. function sliderA_Callback(hObject, eventdata, handles) % hObject handle to sliderA (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,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider slider_value = get(hObject,'Value'); a=floor(10*slider_value); set(handles.texta,'String',a); graphfunction(hObject, eventdata, handles); % --- Executes during object creation, after setting all properties. function sliderA_CreateFcn(hObject, eventdata, handles) % hObject handle to sliderA (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: slider controls usually have a light gray background. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end function edit1_Callback(hObject, eventdata, handles) % hObject handle to edit1 (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 edit1 as text % str2double(get(hObject,'String')) returns contents of edit1 as a double % --- Executes during object creation, after setting all properties. function edit1_CreateFcn(hObject, eventdata, handles) % hObject handle to edit1 (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 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) % -------------------------------------------------------------------- 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) % -------------------------------------------------------------------- function CloseMenuItem_Callback(hObject, eventdata, handles) % 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) function graphfunction(hObject, eventdata, handles) menuValue=get(handles.functionmenu,'Value'); funcString=get(handles.display,'String'); if menuValue>1 cla; f=inline(funcString); a=str2num(get(handles.texta,'String')); b=str2num(get(handles.textb,'String')); c=str2num(get(handles.textc,'String')); d=str2num(get(handles.textd,'String')); %create plot X=linspace(-10,10,300); for i=1:300 Y(i)=f(a,b,c,d,X(i)); end plot(X,Y) axis([-10 10 -10 10]) end