function varargout = guardarf(varargin) % GUARDARF M-file for guardarf.fig % GUARDARF, by itself, creates a new GUARDARF or raises the existing % singleton*. % % H = GUARDARF returns the handle to a new GUARDARF or the handle to % the existing singleton*. % % GUARDARF('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in GUARDARF.M with the given input arguments. % % GUARDARF('Property','Value',...) creates a new GUARDARF or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before guardarf_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to guardarf_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 % Copyright 2002-2003 The MathWorks, Inc. % Edit the above text to modify the response to help guardarf % Last Modified by GUIDE v2.5 12-Nov-2005 20:54:10 %DEFINICIÓN DE FUNCIÓN %Función que solicita al usuario que introduzca los datos que desea %guardar, seleccione la forma de almacenar los datos y posteriormente %almacene los datos seleccionados. %La forma de almacenar los datos es mediante: archivos .mat, archivos .wk1 %y usando informes, tanto en html como en doc %Como parámetros de entrada tenemos todos los posibles datos que se pueden %almacenar. De salida no se devuelve nada. % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @guardarf_OpeningFcn, ... 'gui_OutputFcn', @guardarf_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 guardarf is made visible. function guardarf_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 guardarf (see VARARGIN) % Choose default command line output for guardarf handles.output = hObject; %INICIALIZACIÓN DE VARIABLES flagmat = 0; %0 no se guarda y 1 se guarda en .mat flagwk1 = 0; %0 no se guarda y 1 se guarda en .wk1 flaghtml = 0; %0 no se guarda y 1 se crea un html flagdoc = 0; %0 no se guarda y 1 se crea un doc flagdens = 0; %0 no se ha guarda y 1 se guarda la dens espectral de pot flagpotencia = 0; %0 no se guarda y 1 se guarda la potencia flagglobales = 0; %0 no se guarda y 1 se guarda los máx y min locales flaglocales = 0; %0 no se guarda y 1 se guarda los max y min globales directorio = ''; %Directorio donde almacenamos el archivo *.wk1 nombre = ''; %Nombre del archivo wk1 directoriom= ''; %Directorio donde almacenamos la carpeta mat nombrem = ''; %Nombre de la carpeta mat Pyy = []; %Densidad espectral de Potencia PyyNorm = []; %Densidad espectral de Potencia normalizada PyyPorc = []; %Dens espectral de Pot expresada en % respecto a la Potencia num_puntos = 0; Potencia = []; maximoPotencia = []; minimoPotencia = []; localmaxPot = []; localminPot = []; handles.flagmat = flagmat; handles.flagwk1 = flagwk1; handles.flaghtml = flaghtml; handles.flagdoc = flagdoc; handles.flagdens = flagdens; handles.flagpotencia = flagpotencia; handles.flagglobales = flagglobales; handles.flaglocales = flaglocales; handles.directorio = directorio; handles.nombre = nombre; handles.directoriom = directoriom; handles.nombrem = nombrem; handles.Pyy = varargin{1}; handles.PyyNorm = varargin{2}; handles.PyyPorc = varargin{3}; handles.num_puntos = varargin{4}; handles.Potencia = varargin{5}; handles.maximoPotencia =varargin{6}; handles.minimoPotencia =varargin{7}; handles.localmaxPot = varargin{8}; handles.localminPot = varargin{9}; % Update handles structure guidata(hObject, handles); % UIWAIT makes guardarf wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = guardarf_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 mat_push. function mat_push_Callback(hObject, eventdata, handles) % hObject handle to mat_push (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) %Al pulsar el botón mat, permite almacenar todos los datos seleccionados en %varios archivos .mat ubicados en la carpeta resultadosf. nombrem = ''; directoriom= ''; salir = 0; flagmat = 1; %almacenamos los datos en .mat [nombrem,directorio,salir]=uiputfile('*.*','GUARDARF DATOS'); handles.nombrem=nombrem; handles.directoriom=directoriom; if salir==1 set(handles.mat_push,'BackgroundColor',[0 0 1]); handles.flagmat = flagmat; warndlg(strcat('Al pulsar GUARDAR se creará la carpeta:',directorio,nombrem,'_con los archivos seleccionados'),'AVISO'); else warndlg('AVISO: No se ha seleccionado e formato','AVISO'); end guidata(hObject,handles) % --- Executes on button press in wk1_push. function wk1_push_Callback(hObject, eventdata, handles) % hObject handle to wk1_push (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) %Al pulsar wk1 almacenamos los datos seleccionados en un archivo wk1 cuyo %nombre y directorio lo selecciona el usuario a priori. nombre = ''; directorio = ''; salir = 0; %0 se pulsa el aspa o cancelar, 1 introducimos algún nombre %pintamos el cuadro en azul una vez que se ha pulsado set(handles.wk1_push,'BackgroundColor',[0 0 1]); %solicitamos al usuario que introduzca el nombre del archivo y donde lo %quiere guardar [nombre,directorio,salir]=uiputfile('*.wk1','GUARDARF DATOS'); handles.nombre = nombre; handles.directorio = directorio; if salir==1 handles.flagwk1 = 1; warndlg(strcat('Al pulsar GUARDAR se almacenará:',nombre,'en ',... directorio),'AVISO'); else %si el usuario se sale pulsando el aspa o dando a cancelar no se crea %ningún archivo errordlg('No ha guardado los datos','ERROR') set(handles.wk1_push,'BackgroundColor',[0.925 0.914 0.845]) end guidata(hObject,handles) % --- Executes on button press in html_push. function html_push_Callback(hObject, eventdata, handles) % hObject handle to html_push (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) %Permitimos que se cree el informe html handles.flaghtml=1; set(handles.html_push,'BackgroundColor',[0 0 1]); warndlg('Al pulsar GUARDAR se creará el archivo html') guidata(hObject,handles) % --- Executes on button press in doc_push. function doc_push_Callback(hObject, eventdata, handles) % hObject handle to doc_push (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) %Permitimos que se cree el informe doc set(handles.doc_push,'BackgroundColor',[0 0 1]); handles.flagdoc=1; warndlg('Al pulsar GUARDAR se creará el archivo doc') guidata(hObject,handles) % --- Executes on button press in aceptar_push. function aceptar_push_Callback(hObject, eventdata, handles) % hObject handle to aceptar_push (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) if handles.flaghtml==1 %Deseamos crear el informe con todos los datos de las señales publish('resulf','html'); closereq closereq end %si se ha seleccionado algún procesado pero no dato, podemos cerrar la ventana %en caso contrario damos un aviso y esperamos que introduzca algún dato. if handles.flaghtml==0 & handles.flagdoc==0 warndlg('AVISO: No se ha seleccionado nada para guardar','AVISO'); end % --- Executes on button press in cancelar_push. function cancelar_push_Callback(hObject, eventdata, handles) % hObject handle to cancelar_push (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) closereq % --- Executes on button press in ayuda_push. function ayuda_push_Callback(hObject, eventdata, handles) % hObject handle to ayuda_push (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) helpdlg('Primero seleccione los datos que desea almacenar,posteriormente el formato en que los desea guardar y luego Aceptar','AYUDA'); % --- Executes on button press in deshacer_push. function deshacer_push_Callback(hObject, eventdata, handles) % hObject handle to deshacer_push (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) %Limpiamos todos los datos que se han introducido previamente %e invitamos al usuario a introducirlos de nuevo handles.flaghtml = 0; handles.flagdoc = 0; %Limpiamos todos los botones set(handles.html_push,'BackgroundColor',[0.925 0.914 0.845]) set(handles.doc_push,'BackgroundColor',[0.925 0.914 0.845]) warndlg('Vuelva a seleccionar los informes que desea generar','AVISO') guidata(hObject,handles) % --- Executes on button press in Dens_box. function Dens_box_Callback(hObject, eventdata, handles) % hObject handle to Dens_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) if get(hObject,'Value')==get(hObject,'Max') handles.flagdens = 1; else handles.flagdens =0; end guidata(hObject,handles) % --- Executes on button press in potencia_box. function potencia_box_Callback(hObject, eventdata, handles) % hObject handle to potencia_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) if get(hObject,'Value')==get(hObject,'Max') handles.flagpotencia = 1; else handles.flagpotencia = 0; end guidata(hObject,handles) % --- Executes on button press in globales_box. function globales_box_Callback(hObject, eventdata, handles) % hObject handle to globales_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) if get(hObject,'Value')==get(hObject,'Max') handles.flagglobales =1; else handles.flagglobales = 0; end guidata(hObject,handles) % --- Executes on button press in locales_box. function locales_box_Callback(hObject, eventdata, handles) % hObject handle to locales_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) if get(hObject,'Value')==get(hObject,'Max') handles.flaglocales = 1; else handles.flaglocales = 0; end guidata(hObject,handles); % --- Executes on button press in guardarfich_push. function guardarfich_push_Callback(hObject, eventdata, handles) % hObject handle to guardarfich_push (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) %Una vez seleccionado todos los datos y tipos de archivos que deseamos %generar, al pulsar aceptar se validan todas las operaciones Pyy = handles.Pyy; PyyNorm = handles.PyyNorm; PyyPorc = handles.PyyPorc; num_puntos = handles.num_puntos; Potencia = handles.Potencia; maximoPotencia = handles.maximoPotencia; minimoPotencia = handles.minimoPotencia; localmaxPot = handles.localmaxPot; localminPot = handles.localminPot; directorio = handles.directorio; nombre = handles.nombre; directoriom = handles.directoriom; nombrem = handles.nombrem; A=[]; %Matrices que vamos a usar B=[]; % para crear el archivo wk1 C=[]; [m,n]=size(Pyy); if handles.flagmat==1 %Deseamos crear varios archivos .mat en la carpeta resultadosf, %la cual contiene los datos de sus respectivos nombres direc=pwd; mkdir(directoriom,nombrem) cd(strcat(directoriom,nombrem)) if handles.flagdens==1 save densidadP Pyy num_puntos; end if handles.flagpotencia==1 save potencia Potencia; end if handles.flagglobales==1 save maxminglobales maximoPotencia minimoPotencia; end if handles.flagglobales==1 save maxminlocales localmaxPot localminPot; end cd(direc) end if handles.flagwk1==1 %Deseamos crear un archivo .wk1 con los datos seleccionados por el %usuario en el lugar indicado por éste. if handles.flagdens==1 A=[A, Pyy]; end if handles.flagpotencia==1 B=[ Potencia;zeros(m-1,n)]; A=[A, B]; end if handles.flagglobales==1 C=[maximoPotencia minimoPotencia;zeros(m-1,(2*n))]; A=[A,C]; end if handles.flaglocales==1 A=[A, localmaxPot localminPot]; end wk1write(strcat(directorio,nombre),A); end if handles.flagmat==0 & handles.flagwk1==0 warndlg('AVISO: No se ha seleccionado nada para guardar','AVISO'); end % --- Executes on button press in deshacerfich_push. function deshacerfich_push_Callback(hObject, eventdata, handles) % hObject handle to deshacerfich_push (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.flagmat = 0; handles.flagwk1 = 0; set(handles.wk1_push,'BackgroundColor',[0.925 0.914 0.845]) set(handles.mat_push,'BackgroundColor',[0.925 0.914 0.845]) %Limpiamos los datos que se han seleccionado previamente set(handles.Dens_box,'Value',0); set(handles.potencia_box,'Value',0); set(handles.globales_box,'Value',0); set(handles.locales_box,'Value',0); warndlg('Vuelva a seleccionar los datos que desea generar','AVISO') guidata(hObject,handles) % --- Executes on button press in siguiente_push. function siguiente_push_Callback(hObject, eventdata, handles) % hObject handle to siguiente_push (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) closereq