guidee matlab

31
UNIVERSIDAD NACIONAL DE SAN AGUSTIN DE AREQUIPA FACULTAD DE PRODUCCION Y SERVICIOS SOFTWARE APLICADO A LA INGENIERIA MATLAB TEMA: MATLAB: INTERFAZ GRAFICA ‘GUIDE’ ALUMNO: ZAPANA COLQUE JUAN EDGAR CUI: 20082258 Grupo “A” DOCENTE: ING. LUIS MERCADO

Upload: edgar-zapana

Post on 01-Oct-2015

271 views

Category:

Documents


2 download

DESCRIPTION

Guide matlab

TRANSCRIPT

UNIVERSIDAD NACIONAL DE SAN AGUSTIN DE AREQUIPAFACULTAD DE PRODUCCION Y SERVICIOS

SOFTWARE APLICADO A LA INGENIERIAMATLAB

TEMA: MATLAB: INTERFAZ GRAFICA GUIDE ALUMNO: ZAPANA COLQUE JUAN EDGARCUI: 20082258 Grupo A DOCENTE: ING. LUIS MERCADOAREQUIPA 2012RESOLUCION DE LOS CIRCUITOS BASICOS DE OPAMCon el popupmenu1 se elige que tipo de configuracin se desea utilizarCon el slider se pude modificar la frecuencia de entrada de la onda. Esto se modifica al presionar el botn resolverLos datos de entrada se restringen, si se ingresa resistencias negativas o cualquiera letra sale un mensaje de error.Al ingresar los datos correctos al presionar el botn resolver se resuelve y muestra en los axes el circuito bsico, la onda de salida y entrada y con el segundo slider se puede variar el tiempo en el grafico.Los datos de salida Vo esta restringa si excede los 15 voltios de la fuente de alimentacin sale un mensaje diciendo que la onda fue recortada. Y esto se puede mostrar en el grafico.Tiene el botn reset. Cuando se cambia de circuito a otro circuito se resetea segn los datos que pide.Tiene la opcin de salir dando un mensaje de confirmacin.Se puede guardar la grafica de los voltajes de entrada y salida en bmp.

function varargout = amplificador(varargin)% AMPLIFICADOR M-file for amplificador.fig% AMPLIFICADOR, by itself, creates a new AMPLIFICADOR or raises the existing% singleton*.%% H = AMPLIFICADOR returns the handle to a new AMPLIFICADOR or the handle to% the existing singleton*.%% AMPLIFICADOR('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in AMPLIFICADOR.M with the given input arguments.%% AMPLIFICADOR('Property','Value',...) creates a new AMPLIFICADOR or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before amplificador_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to amplificador_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 amplificador % Last Modified by GUIDE v2.5 19-Jan-2012 23:16:10 % Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @amplificador_OpeningFcn, ... 'gui_OutputFcn', @amplificador_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 amplificador is made visible.function amplificador_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 amplificador (see VARARGIN)handles.output = hObject;axes(handles.axes4)a=imread('images.jpg');image(a);axis offaxes(handles.axes1)axis offaxes(handles.axes6)axis offaxes(handles.axes3)axis off% Choose default command line output for amplificador%handles.output = hObject;%------------- Add Background --------------------% % Update handles structureguidata(hObject, handles); % UIWAIT makes amplificador wait for user response (see UIRESUME)% uiwait(handles.figure1); % --- Outputs from this function are returned to the command line.function varargout = amplificador_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 structurevarargout{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 as cell array% contents{get(hObject,'Value')} returns selected item from popupmenu1switch get(handles.popupmenu1,'Value') case 1 axes(handles.axes1);imshow('blanco.png');axis offset(handles.edit1_R1,'Visible', 'on')set(handles.text1_R1,'Visible', 'on')set(handles.text7_uR1,'Visible', 'on')set(handles.edit2_R2,'Visible', 'on')set(handles.text2_R2,'Visible', 'on')set(handles.text8_uR2,'Visible', 'on')set(handles.edit3_RF,'Visible', 'on')set(handles.text3_RF,'Visible', 'on')set(handles.text9_uRF,'Visible', 'on')set(handles.edit4_Vin1,'Visible', 'on')set(handles.text4_Vin1,'Visible', 'on')set(handles.text10_uVin1,'Visible', 'on')set(handles.edit5_Vin2,'Visible', 'on')set(handles.text5_Vin2,'Visible', 'on')set(handles.text11_uVin2,'Visible', 'on')set(handles.edit6_Vo,'Visible', 'on')set(handles.text6_Vo,'Visible', 'on')set(handles.text12_uVo,'Visible', 'on')set(handles.edit7,'string', ' 0 ')set(handles.slider4, 'value', 0)set(handles.edit1_R1,'string', ' ')set(handles.edit2_R2,'string', ' ')set(handles.edit3_RF,'string', ' ')set(handles.edit4_Vin1,'string', ' ')set(handles.edit5_Vin2,'string', ' ')set(handles.edit6_Vo,'string', ' ')set(handles.edit7,'string', ' 0 ')set(handles.edit8,'string', ' 1 ')set(handles.slider5, 'value', 1)endswitch get(handles.popupmenu1,'Value') case 2axes(handles.axes1);imshow('inversor.png');axis offset(handles.edit1_R1,'Visible', 'on')set(handles.text1_R1,'Visible', 'on')set(handles.text7_uR1,'Visible', 'on')set(handles.edit2_R2,'Visible', 'off')set(handles.text2_R2,'Visible', 'off')set(handles.text8_uR2,'Visible', 'off')set(handles.edit3_RF,'Visible', 'on')set(handles.text3_RF,'Visible', 'on')set(handles.text9_uRF,'Visible', 'on')set(handles.edit4_Vin1,'Visible', 'on')set(handles.text4_Vin1,'Visible', 'on')set(handles.text10_uVin1,'Visible', 'on')set(handles.edit5_Vin2,'Visible', 'off')set(handles.text5_Vin2,'Visible', 'off')set(handles.text11_uVin2,'Visible', 'off')set(handles.edit6_Vo,'Visible', 'on')set(handles.text6_Vo,'Visible', 'on')set(handles.text12_uVo,'Visible', 'on')set(handles.edit1_R1,'string', ' ')set(handles.edit2_R2,'string', ' ')set(handles.edit3_RF,'string', ' ')set(handles.edit4_Vin1,'string', ' ')set(handles.edit5_Vin2,'string', ' ')set(handles.edit6_Vo,'string', ' ')set(handles.edit7,'string', ' 0 ')set(handles.slider4, 'value', 0)set(handles.edit1_R1,'string', ' ')set(handles.edit2_R2,'string', ' ')set(handles.edit3_RF,'string', ' ')set(handles.edit4_Vin1,'string', ' ')set(handles.edit5_Vin2,'string', ' ')set(handles.edit6_Vo,'string', ' ')set(handles.edit7,'string', ' 0 ')set(handles.edit8,'string', ' 1 ')set(handles.slider5, 'value', 1)axes(handles.axes3)claaxes(handles.axes6)claendswitch get(handles.popupmenu1,'Value') case 3axes(handles.axes1);imshow('noinversor.png');axis offset(handles.edit1_R1,'Visible', 'on')set(handles.text1_R1,'Visible', 'on')set(handles.text7_uR1,'Visible', 'on')set(handles.edit2_R2,'Visible', 'off')set(handles.text2_R2,'Visible', 'off')set(handles.text8_uR2,'Visible', 'off')set(handles.edit3_RF,'Visible', 'on')set(handles.text3_RF,'Visible', 'on')set(handles.text9_uRF,'Visible', 'on')set(handles.edit4_Vin1,'Visible', 'on')set(handles.text4_Vin1,'Visible', 'on')set(handles.text10_uVin1,'Visible', 'on')set(handles.edit5_Vin2,'Visible', 'off')set(handles.text5_Vin2,'Visible', 'off')set(handles.text11_uVin2,'Visible', 'off')set(handles.edit6_Vo,'Visible', 'on')set(handles.text6_Vo,'Visible', 'on')set(handles.text12_uVo,'Visible', 'on')set(handles.edit7,'string', ' 0 ')set(handles.slider4, 'value', 0)set(handles.edit1_R1,'string', ' ')set(handles.edit2_R2,'string', ' ')set(handles.edit3_RF,'string', ' ')set(handles.edit4_Vin1,'string', ' ')set(handles.edit5_Vin2,'string', ' ')set(handles.edit6_Vo,'string', ' ')set(handles.edit7,'string', ' 0 ')set(handles.edit8,'string', ' 1 ')set(handles.slider5, 'value', 1)axes(handles.axes3)claaxes(handles.axes6)claendswitch get(handles.popupmenu1,'Value') case 4axes(handles.axes1);imshow('sumador.png');axis offset(handles.edit1_R1,'Visible', 'on')set(handles.text1_R1,'Visible', 'on')set(handles.text7_uR1,'Visible', 'on')set(handles.edit2_R2,'Visible', 'on')set(handles.text2_R2,'Visible', 'on')set(handles.text8_uR2,'Visible', 'on')set(handles.edit3_RF,'Visible', 'on')set(handles.text3_RF,'Visible', 'on')set(handles.text9_uRF,'Visible', 'on')set(handles.edit4_Vin1,'Visible', 'on')set(handles.text4_Vin1,'Visible', 'on')set(handles.text10_uVin1,'Visible', 'on')set(handles.edit5_Vin2,'Visible', 'on')set(handles.text5_Vin2,'Visible', 'on')set(handles.text11_uVin2,'Visible', 'on')set(handles.edit6_Vo,'Visible', 'on')set(handles.text6_Vo,'Visible', 'on')set(handles.text12_uVo,'Visible', 'on')set(handles.edit7,'string', ' 0 ')set(handles.slider4, 'value', 0)set(handles.edit1_R1,'string', ' ')set(handles.edit2_R2,'string', ' ')set(handles.edit3_RF,'string', ' ')set(handles.edit4_Vin1,'string', ' ')set(handles.edit5_Vin2,'string', ' ')set(handles.edit6_Vo,'string', ' ')set(handles.edit7,'string', ' 0 ')set(handles.edit8,'string', ' 1 ')set(handles.slider5, 'value', 1)axes(handles.axes3)claaxes(handles.axes6)cla 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,'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)%axes(handles.axes3)%claaxes(handles.axes3)claaxes(handles.axes6)set(handles.edit7,'string', ' 0 ')set(handles.slider4, 'value', 0)claswitch get(handles.popupmenu1,'Value') case 2 Vin = str2double(get(handles.edit4_Vin1,'string')) R1 = str2double(get(handles.edit1_R1,'String')) RF = str2double(get(handles.edit3_RF,'string')) f = str2double(get(handles.edit8,'string')) if R1>=0 & RF>=0 Resut=-RF/R1; Vo=Resut*Vin; set(handles.edit6_Vo,'String',num2str(Vo)) w=2*pi*f; fuenteDC=15; t=0:0.01:3; Vin_Plot=Vin*sin(t*w); Vo_Plot=Vo*sin(t*w); if abs(Vo)fuenteDC) Vo_Plot(i)= fuenteDC; elseif (Vo_Plot(i) < -fuenteDC) Vo_Plot(i)= -fuenteDC; end end plot(t,Vin_Plot,'RED' ,'linewidth',1) hold on plot(t, Vo_Plot,'GREEN' ,'linewidth',1) grid on axis([ 0 max(t) -20 20]) xlabel('Tiempo (t)','fontweight','bold') ylabel('Entrada y salida del voltaje (V)','fontweight','bold') legend('Vin','Vo'); end if abs(Vo) > 15 msgboxText{1} = 'ONDA DE SALIDA RECORTADA!'; msgbox(msgboxText,'ALERTA...','warn'); end else Warndlg ('Solo datos numericos y resistencias positivas...!!!','Vuelva a introducir los datos') end case 3 Vin = str2double(get(handles.edit4_Vin1,'string')) R1 = str2double(get(handles.edit1_R1,'String')) RF = str2double(get(handles.edit3_RF,'string')) f = str2double(get(handles.edit8,'string')) if Vin>=0 & R1>=0 & RF>=0 Vo=Vin*(1+(RF/R1)) set(handles.edit6_Vo,'String',num2str(Vo)) w=2*pi*f; fuenteDC=15; t=0:0.01:3; Vin_Plot=Vin*sin(t*w); Vo_Plot=Vo*sin(t*w); if abs(Vo)fuenteDC) Vo_Plot(i)= fuenteDC; elseif (Vo_Plot(i) < -fuenteDC) Vo_Plot(i)= -fuenteDC; end end plot(t,Vin_Plot,'RED' ,'linewidth',1) hold on plot(t, Vo_Plot,'GREEN' ,'linewidth',1) grid on axis([ 0 max(t) -20 20]) xlabel('Tiempo (t)','fontweight','bold') ylabel('Entrada y salida del voltaje (V)','fontweight','bold') legend('Vin','Vo'); end if abs(Vo) > 15 msgboxText{1} = 'ONDA DE SALIDA RECORTADA!'; msgbox(msgboxText,'ALERTA...','warn'); end else Warndlg ('Solo datos numericos y resistencias positivas...!!!','Vuelva a introducir los datos') end case 4 Vin1 = str2double(get(handles.edit4_Vin1,'string')) Vin2 = str2double(get(handles.edit5_Vin2,'string')) R1 = str2double(get(handles.edit1_R1,'String')) R2 = str2double(get(handles.edit2_R2,'String')) RF = str2double(get(handles.edit3_RF,'string')) f = str2double(get(handles.edit8,'string')) if Vin1>=0 & R1>=0 & RF>=0 & R2>=0 & Vin2>=0 a1=Vin1/R1; a2=Vin2/R2; Vo=-RF*(a1+a2); set(handles.edit6_Vo,'String',num2str(Vo)); w=2*pi*f; fuenteDC=15; t=0:0.01:3; Vin_Plot1=Vin1*sin(t*w); Vin_Plot2=Vin2*sin(t*w); Vo_Plot=Vo*sin(t*w); if abs(Vo)fuenteDC) Vo_Plot(i)= fuenteDC; elseif (Vo_Plot(i) < -fuenteDC) Vo_Plot(i)= -fuenteDC; end end plot(t,Vin_Plot1,'RED','linewidth',1); hold on plot(t,Vin_Plot2,'BLUE','linewidth',1); hold off hold on plot(t,Vo_Plot,'GREEN','linewidth',1); hold off grid on axis([ 0 max(t) -20 20]) xlabel('Tiempo (t)','fontweight','bold') ylabel('Entrada y salida del voltaje (V)','fontweight','bold') legend('Vin1','Vin2','Vo'); end if abs(Vo) > 15 msgboxText{1} = 'ONDA DE SALIDA RECORTADA!'; msgbox(msgboxText,'ALERTA...','warn'); end else Warndlg ('Solo datos numericos y resistencias positivas...!!!','Vuelva a introducir los datos') end end% --- Executes on button press in pushbutton2.function pushbutton2_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)set(handles.edit1_R1,'string', ' ')set(handles.edit2_R2,'string', ' ')set(handles.edit3_RF,'string', ' ')set(handles.edit4_Vin1,'string', ' ')set(handles.edit5_Vin2,'string', ' ')set(handles.edit6_Vo,'string', ' ')set(handles.edit7,'string', ' 0 ')set(handles.popupmenu1, 'value', 1)set(handles.slider4, 'value', 0)set(handles.edit8,'string', ' 1 ')set(handles.slider5, 'value', 1)axes(handles.axes1);imshow('blanco.png');axes(handles.axes3);%axes(handles.axes5);cla % Clear current axisaxes(handles.axes6);claset(handles.edit1_R1,'Visible', 'on')set(handles.text1_R1,'Visible', 'on')set(handles.text7_uR1,'Visible', 'on')set(handles.edit2_R2,'Visible', 'on')set(handles.text2_R2,'Visible', 'on')set(handles.text8_uR2,'Visible', 'on')set(handles.edit3_RF,'Visible', 'on')set(handles.text3_RF,'Visible', 'on')set(handles.text9_uRF,'Visible', 'on')set(handles.edit4_Vin1,'Visible', 'on')set(handles.text4_Vin1,'Visible', 'on')set(handles.text10_uVin1,'Visible', 'on')set(handles.edit5_Vin2,'Visible', 'on')set(handles.text5_Vin2,'Visible', 'on')set(handles.text11_uVin2,'Visible', 'on')set(handles.edit6_Vo,'Visible', 'on')set(handles.text6_Vo,'Visible', 'on')set(handles.text12_uVo,'Visible', 'on') % --- Executes on button press in pushbutton3.function pushbutton3_Callback(hObject, eventdata, handles)% hObject handle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) ans=questdlg('Desea salir del programa?','SALIR','Si','No','No'); if strcmp(ans,'No') return; end%clear,clc,close alset(amplificador,'Visible','off') function edit6_Vo_Callback(hObject, eventdata, handles)% hObject handle to edit6_Vo (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 edit6_Vo as text% str2double(get(hObject,'String')) returns contents of edit6_Vo as a double % --- Executes during object creation, after setting all properties.function edit6_Vo_CreateFcn(hObject, eventdata, handles)% hObject handle to edit6_Vo (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 edit1_R1_Callback(hObject, eventdata, handles)% hObject handle to edit1_R1 (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_R1 as text% str2double(get(hObject,'String')) returns contents of edit1_R1 as a double % --- Executes during object creation, after setting all properties.function edit1_R1_CreateFcn(hObject, eventdata, handles)% hObject handle to edit1_R1 (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 edit2_R2_Callback(hObject, eventdata, handles)% hObject handle to edit2_R2 (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 edit2_R2 as text% str2double(get(hObject,'String')) returns contents of edit2_R2 as a double % --- Executes during object creation, after setting all properties.function edit2_R2_CreateFcn(hObject, eventdata, handles)% hObject handle to edit2_R2 (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 edit3_RF_Callback(hObject, eventdata, handles)% hObject handle to edit3_RF (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 edit3_RF as text% str2double(get(hObject,'String')) returns contents of edit3_RF as a double % --- Executes during object creation, after setting all properties.function edit3_RF_CreateFcn(hObject, eventdata, handles)% hObject handle to edit3_RF (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 edit4_Vin1_Callback(hObject, eventdata, handles)% hObject handle to edit4_Vin1 (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 edit4_Vin1 as text% str2double(get(hObject,'String')) returns contents of edit4_Vin1 as a double % --- Executes during object creation, after setting all properties.function edit4_Vin1_CreateFcn(hObject, eventdata, handles)% hObject handle to edit4_Vin1 (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 edit5_Vin2_Callback(hObject, eventdata, handles)% hObject handle to edit5_Vin2 (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 edit5_Vin2 as text% str2double(get(hObject,'String')) returns contents of edit5_Vin2 as a double % --- Executes during object creation, after setting all properties.function edit5_Vin2_CreateFcn(hObject, eventdata, handles)% hObject handle to edit5_Vin2 (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 slider movement.function slider4_Callback(hObject, eventdata, handles)% hObject handle to slider4 (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 %set(handles.op_selec,'String','Slider'); value=get(hObject,'Value');set(handles.edit7,'String',value);axes(handles.axes3)claswitch get(handles.popupmenu1,'Value') case 2 Vin = str2double(get(handles.edit4_Vin1,'string')) R1 = str2double(get(handles.edit1_R1,'String')) RF = str2double(get(handles.edit3_RF,'string')) f = str2double(get(handles.edit8,'string')) Resut=-RF/R1; Vo=Resut*Vin; fuenteDC=15; fc=value; t=0:0.01:fc; w=2*pi*f; Vin_Plot=Vin*sin(t*w); Vo_Plot=Vo*sin(t*w); if abs(Vo)fuenteDC) Vo_Plot(i)= fuenteDC; elseif (Vo_Plot(i) < -fuenteDC) Vo_Plot(i)= -fuenteDC; end end plot(t,Vin_Plot,'RED' ,'linewidth',1) hold on plot(t, Vo_Plot,'GREEN' ,'linewidth',1) grid on axis([ 0 max(t) -30 30]) xlabel('Tiempo (t)','fontweight','bold') ylabel('Entrada y salida del voltaje (V)','fontweight','bold') legend('Vin','Vo'); end case 3 Vin = str2double(get(handles.edit4_Vin1,'string')) R1 = str2double(get(handles.edit1_R1,'String')) RF = str2double(get(handles.edit3_RF,'string')) f = str2double(get(handles.edit8,'string')) Vo=Vin*(1+(RF/R1)) fuenteDC=15; fc=value; t=0:0.01:fc; w=2*pi*f; Vin_Plot=Vin*sin(t*w); Vo_Plot=Vo*sin(t*w); if abs(Vo)fuenteDC) Vo_Plot(i)= fuenteDC; elseif (Vo_Plot(i) < -fuenteDC) Vo_Plot(i)= -fuenteDC; end end plot(t,Vin_Plot,'RED' ,'linewidth',1) hold on plot(t, Vo_Plot,'GREEN' ,'linewidth',1) grid on axis([ 0 max(t) -30 30]) xlabel('Tiempo (t)','fontweight','bold') ylabel('Entrada y salida del voltaje (V)','fontweight','bold') legend('Vin','Vo'); end case 4 Vin1 = str2double(get(handles.edit4_Vin1,'string')) Vin2 = str2double(get(handles.edit5_Vin2,'string')) R1 = str2double(get(handles.edit1_R1,'String')) R2 = str2double(get(handles.edit2_R2,'String')) RF = str2double(get(handles.edit3_RF,'string')) f = str2double(get(handles.edit8,'string')) a1=Vin1/R1; a2=Vin2/R2; Vo=-RF*(a1+a2); set(handles.edit6_Vo,'String',num2str(Vo)); w=2*pi*f; fuenteDC=15; fc=value; t=0:0.01:fc; w=2*pi*f; Vin_Plot1=Vin1*sin(t*w); Vin_Plot2=Vin2*sin(t*w); Vo_Plot=Vo*sin(t*w); if abs(Vo)fuenteDC) Vo_Plot(i)= fuenteDC; elseif (Vo_Plot(i) < -fuenteDC) Vo_Plot(i)= -fuenteDC; end end plot(t,Vin_Plot1,'RED','linewidth',1); hold on plot(t,Vin_Plot2,'BLUE','linewidth',1); hold off hold on plot(t,Vo_Plot,'GREEN','linewidth',1); hold off grid on axis([ 0 max(t) -20 20]) xlabel('Tiempo (t)','fontweight','bold') ylabel('Entrada y salida del voltaje (V)','fontweight','bold') legend('Vin1','Vin2','Vo'); endend function slider4_CreateFcn(hObject, eventdata, handles)% hObject handle to slider4 (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 edit7_Callback(hObject, eventdata, handles)% hObject handle to edit7 (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 edit7 as text% str2double(get(hObject,'String')) returns contents of edit7 as a double % --- Executes during object creation, after setting all properties.function edit7_CreateFcn(hObject, eventdata, handles)% hObject handle to edit7 (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 pushbutton4.function pushbutton4_Callback(hObject, eventdata, handles)% hObject handle to pushbutton4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Guardar imagen% Obtener imagen del axesgetimage(handles.axes6);formatos = {'*.bmp','BMP (*.bmp)'};[nomb,ruta] = uiputfile(formatos,'GUARDAR LA IMAGEN DEL GRAFICO');% Crear nueva figurafigura = figure;% Unidades y posicinunidades = get(handles.axes6,'Units');posicion = get(handles.axes6,'Position');objeto_2 = copyobj(handles.axes6,figura);% Modificar la nueva figuraset(objeto_2,'Units',unidades);set(objeto_2,'Position',[15 5 posicion(3) posicion(4)]);% Ajustar la nueva figuraset(figura,'Units',unidades);set(figura,'Position',[15 5 posicion(3)+30 posicion(4)+10]);% Guardar la grficasaveas(figura,[ruta nomb]) %Cerrar figuraclose(figura) function edit8_Callback(hObject, eventdata, handles)% hObject handle to edit8 (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 edit8 as text% str2double(get(hObject,'String')) returns contents of edit8 as a double % --- Executes during object creation, after setting all properties.function edit8_CreateFcn(hObject, eventdata, handles)% hObject handle to edit8 (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 slider movement.function slider5_Callback(hObject, eventdata, handles)% hObject handle to slider5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)value=get(hObject,'Value');set(handles.edit8,'String',value);% Hints: get(hObject,'Value') returns position of slider% get(hObject,'Min') and get(hObject,'Max') to determine range of slider % --- Executes during object creation, after setting all properties.function slider5_CreateFcn(hObject, eventdata, handles)% hObject handle to slider5 (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]);