Anda di halaman 1dari 4

function varargout = crecimiento(varargin)

% CRECIMIENTO MATLAB code for crecimiento.fig


%
CRECIMIENTO, by itself, creates a new CRECIMIENTO or raises the existing
%
singleton*.
%
%
H = CRECIMIENTO returns the handle to a new CRECIMIENTO or the handle to
%
the existing singleton*.
%
%
CRECIMIENTO('CALLBACK',hObject,eventData,handles,...) calls the local
%
function named CALLBACK in CRECIMIENTO.M with the given input arguments.
%
%
CRECIMIENTO('Property','Value',...) creates a new CRECIMIENTO or raises t
he
%
existing singleton*. Starting from the left, property value pairs are
%
applied to the GUI before crecimiento_OpeningFcn gets called. An
%
unrecognized property name or invalid value makes property application
%
stop. All inputs are passed to crecimiento_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 crecimiento
% Last Modified by GUIDE v2.5 24-May-2014 00:51:42
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @crecimiento_OpeningFcn, ...
'gui_OutputFcn', @crecimiento_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 crecimiento is made visible.
function crecimiento_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 crecimiento (see VARARGIN)
% Choose default command line output for crecimiento
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);

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


% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = crecimiento_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 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 = cellstr(get(hObject,'String')) returns popupmenu1 contents a
s cell array
%
contents{get(hObject,'Value')} returns selected item from popupmenu1
modelos=get(hObject,'value');
switch modelos
case 1
%diagrama de dispersion
t=[1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913
,1914,1915,1916,1917,1918,1919,1920];
p=[4,6.1,9.8,35.2, 59.4,41.7,19,13,8.3,9.1,7.4,8,12.3,19.5,45.7 51.1, 29
.7, 15.8,9.7,10.1,8.6];
axes(handles.axes1)
plot(t,p,'bo')
title('Crecimiento de la poblacion del depredador (lince)')
xlabel('Tiempo(aos)')
ylabel('poblacion(millones)')
grid on
case 2
t=[1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913
,1914,1915,1916,1917,1918,1919,1920];
p=[4,6.1,9.8,35.2, 59.4,41.7,19,13,8.3,9.1,7.4,8,12.3,19.5,45.7 51.1, 29
.7, 15.8,9.7,10.1,8.6];
l=polyfit(t,p,1);%Ajusta polinomios, entrega los coeficientes de los pol
inomios
lineal=l(1)*t+l(2);
axes(handles.axes3)
plot(t,p,'bo',t,lineal,'r')
title('Crecimiento de la poblacion del depredador (lince)')
xlabel('Tiempo(aos)')
ylabel('Poblacin(Millones)')
grid on
case 3
t=[1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913
,1914,1915,1916,1917,1918,1919,1920];
p=[4,6.1,9.8,35.2, 59.4,41.7,19,13,8.3,9.1,7.4,8,12.3,19.5,45.7 51.1, 29
.7, 15.8,9.7,10.1,8.6];
c=polyfit(t,p,2);
cuadratica=c(1)*t.^2 + c(2)*t + c(3);

axes(handles.axes4)
plot(t,p,'bo',t,cuadratica,'r')
title('Crecimiento de la poblacion del depredador (lince)')
xlabel('Tiempo(aos)')
ylabel('Poblacin(Millones)')
grid on
case 4
t=[1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913
,1914,1915,1916,1917,1918,1919,1920];
p=[4,6.1,9.8,35.2, 59.4,41.7,19,13,8.3,9.1,7.4,8,12.3,19.5,45.7 51.1, 29
.7, 15.8,9.7,10.1,8.6];
cu=polyfit(t,p,3);
cubico=cu(1)*t.^3 + cu(2)*t.^2 + cu(3)*t + cu(4);
axes(handles.axes5)
plot(t,p,'bo',t,cubico,'r')
title('Crecimiento de la poblacion del depredador (lince)')
xlabel('Tiempo(aos)')
ylabel('Poblacin(Millones)')
grid on
case 5
t=[1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913
,1914,1915,1916,1917,1918,1919,1920];
p=[4,6.1,9.8,35.2, 59.4,41.7,19,13,8.3,9.1,7.4,8,12.3,19.5,45.7 51.1, 29
.7, 15.8,9.7,10.1,8.6];
lnp=log(p);
e=polyfit(t,lnp,1);
exponencial=exp(e(2))*exp(e(1)+t);
axes(handles.axes6)
plot(t,p,'bo',t,exponencial,'r')
title('Crecimiento de la poblacion del depredador (lince)')
xlabel('Tiempo(aos)')
ylabel('Poblacin(Millones)')
grid on
otherwise
close(gcbf)
end

% --- 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,'defaultUicontrolBackgr
oundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes during object creation, after setting all properties.
function axes1_CreateFcn(hObject, eventdata, handles)
% hObject
handle to axes1 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB


% handles
empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate axes1
%diagrama de dispersion

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


function axes3_CreateFcn(hObject, eventdata, handles)
% hObject
handle to axes3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate axes3