0% found this document useful (0 votes)
80 views5 pages

Function: 'Gui - Name' 'Gui - Singleton' 'Gui - Openingfcn' 'Gui - Outputfcn' 'Gui - Layoutfcn' 'Gui - Callback'

This document contains MATLAB code for a GUI called graficadort. It includes functions for initializing the GUI, plotting graphs on axes within the GUI, and populating a table with data from the graph. The code takes user input of an equation, x-range, step size and plots the equation over the range. It also plots a scaled version of the equation in red on the same axes. The x and y data is then added to a table within the GUI.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views5 pages

Function: 'Gui - Name' 'Gui - Singleton' 'Gui - Openingfcn' 'Gui - Outputfcn' 'Gui - Layoutfcn' 'Gui - Callback'

This document contains MATLAB code for a GUI called graficadort. It includes functions for initializing the GUI, plotting graphs on axes within the GUI, and populating a table with data from the graph. The code takes user input of an equation, x-range, step size and plots the equation over the range. It also plots a scaled version of the equation in red on the same axes. The x and y data is then added to a table within the GUI.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

function varargout = graficadort(varargin)

% GRAFICADORT MATLAB code for graficadort.fig


% GRAFICADORT, by itself, creates a new GRAFICADORT or raises the
existing
% singleton*.
%
% H = GRAFICADORT returns the handle to a new GRAFICADORT or the
handle to
% the existing singleton*.
%
% GRAFICADORT('CALLBACK',hObject,eventData,handles,...) calls the
local
% function named CALLBACK in GRAFICADORT.M with the given input
arguments.
%
% GRAFICADORT('Property','Value',...) creates a new GRAFICADORT or
raises the
% existing singleton*. Starting from the left, property value pairs
are
% applied to the GUI before graficadort_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property
application
% stop. All inputs are passed to graficadort_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 graficadort

% Last Modified by GUIDE v2.5 29-Oct-2019 08:10:28

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @graficadort_OpeningFcn, ...
'gui_OutputFcn', @graficadort_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

%codigo para inizializar


% --- Executes just before graficadort is made visible.
function graficadort_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 graficadort (see VARARGIN)

% Choose default command line output for graficadort


handles.output = hObject;

% Update handles structure


guidata(hObject, handles);

% UIWAIT makes graficadort wait for user response (see UIRESUME)


% uiwait(handles.figure1);

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

function txt_ecuacion_Callback(hObject, eventdata, handles)


% hObject handle to txt_ecuacion (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 txt_ecuacion as text


% str2double(get(hObject,'String')) returns contents of
txt_ecuacion as a double

% --- Executes during object creation, after setting all properties.


function txt_ecuacion_CreateFcn(hObject, eventdata, handles)
% hObject handle to txt_ecuacion (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 txt_xi_Callback(hObject, eventdata, handles)
% hObject handle to txt_xi (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 txt_xi as text


% str2double(get(hObject,'String')) returns contents of txt_xi as
a double

% --- Executes during object creation, after setting all properties.


function txt_xi_CreateFcn(hObject, eventdata, handles)
% hObject handle to txt_xi (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 txt_xd_Callback(hObject, eventdata, handles)


% hObject handle to txt_xd (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 txt_xd as text


% str2double(get(hObject,'String')) returns contents of txt_xd as
a double

% --- Executes during object creation, after setting all properties.


function txt_xd_CreateFcn(hObject, eventdata, handles)
% hObject handle to txt_xd (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 txt_paso_Callback(hObject, eventdata, handles)


% hObject handle to txt_paso (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 txt_paso as text


% str2double(get(hObject,'String')) returns contents of txt_paso
as a double

% --- Executes during object creation, after setting all properties.


function txt_paso_CreateFcn(hObject, eventdata, handles)
% hObject handle to txt_paso (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 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)

ecuacion=get(handles.txt_ecuacion,'string');
xi=str2double(get(handles.txt_xi,'string')); %str2double es para
tranformar a numero
xd=str2double(get(handles.txt_xd,'string'));
paso=str2double(get(handles.txt_paso,'string'));
x=xi:paso:xd; %es como un for
y=eval(ecuacion);
%plot(x,y);
ecuacion2='x.*x-10'; %funcion cuadrada
y2=eval(ecuacion2); %me va a evaluar la funcion
y2=0.1*y2;
plot(handles.axes1,x,y,'b',x,y2,'r'); %se dibuja 2 funciones en la misma
axes
grid (handles.axes1,'on'); %sacan las cuadriculas en donde yo quiero
axes1

matriz=[x',y',y2']; %cuando pongo transpuesto se va ordenando no sale


todo en una fila
%whos; %me dice que estoy haciendo me da descripcion
set(handles.tbl_mitabla,'data',matriz); %enio datos a mi tabla en gui
nombre={'x','y','y2'}; %las llaves son celdas
set(handles.tbl_mitabla,'columnname',nombre);

% --- Executes when entered data in editable cell(s) in tbl_mitabla.


function tbl_mitabla_CellEditCallback(hObject, eventdata, handles)
% hObject handle to tbl_mitabla (see GCBO)
% eventdata structure with the following fields (see
MATLAB.UI.CONTROL.TABLE)
% Indices: row and column indices of the cell(s) edited
% PreviousData: previous data for the cell(s) edited
% EditData: string(s) entered by the user
% NewData: EditData or its converted form set on the Data property.
Empty if Data was not changed
% Error: error string when failed to convert EditData to appropriate
value for Data
% handles structure with handles and user data (see GUIDATA)

You might also like