Matlab - estructuras en matlab

 
Vista:
sin imagen de perfil

estructuras en matlab

Publicado por FELIPE (4 intervenciones) el 28/11/2014 21:54:48
Hola que tal, tengo una duda, es la siguiente:
Estoy realizando una interfaz grafica en Matlab, el usuario debe ingresar sus datos como son: Nombre(s), Apellido Paterno y Apellido Materno. Estos datos deben guardarse en una estructura de datos para despues poder usarlos nuevamente.
El problema radica en que al momento de que se ingresa otro usuario se borra la informacion anterior.
estoy intentando hacer esto:


usuario(n)=struct('Nombres', '', 'Ap_paterno', '', Ap_materno, '')


lo que deseo es que al momento de que un usuario nuevo ingrese datos no se borren los anteriores, la instruccion anterior lo que debe hacer es ir aumentando (n) para ocupar un nuevo espacio dentro de la estructura. Intuyo que podria ser con un for o un while pero no se bien como plantearlo.

Por cierto tambien quiero saber si dentro de esta estructura de datos es posible guardar archivos de audio en formato .wav. Si es posible quisiera saber como se logra.

Agradeceria mucho si alguien puede ayudarme
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de JOSE JEREMIAS CABALLERO
Val: 6.975
Oro
Ha mantenido su posición en Matlab (en relación al último mes)
Gráfica de Matlab

estructuras en matlab

Publicado por JOSE JEREMIAS CABALLERO (5917 intervenciones) el 29/11/2014 16:02:08
Podrias subir el código completo tanto fig y el m. Para que cambie el valor de n, n tiene que ser una variable global.


..Saludos.
JOSE JEREMÍAS CABALLERO
Asesoría online
programador en matlab
Servicios de programación matlab
[email protected]
Estimado Usuario de Matlab, el correo es para servicios de cursos, asesoría y programación. Toda ayuda gratuita es vía foro.


http://matlabcaballero.blogspot.com

http://www.lawebdelprogramador.com/foros/Matlab/1371532-FORMA_DE_APRENDER_MATLAB.html
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

estructuras en matlab

Publicado por FELIPE (4 intervenciones) el 29/11/2014 19:44:37
este es el codigo que llevo hasta el momento...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
function varargout = INTERFAZ_1(varargin)
% INTERFAZ_1 MATLAB code for INTERFAZ_1.fig
%      INTERFAZ_1, by itself, creates a new INTERFAZ_1 or raises the existing
%      singleton*.
%
%      H = INTERFAZ_1 returns the handle to a new INTERFAZ_1 or the handle to
%      the existing singleton*.
%
%      INTERFAZ_1('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in INTERFAZ_1.M with the given input arguments.
%
%      INTERFAZ_1('Property','Value',...) creates a new INTERFAZ_1 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before INTERFAZ_1_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to INTERFAZ_1_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 INTERFAZ_1

% Last Modified by GUIDE v2.5 25-Nov-2014 13:52:49

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @INTERFAZ_1_OpeningFcn, ...
                   'gui_OutputFcn',  @INTERFAZ_1_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 INTERFAZ_1 is made visible.
function INTERFAZ_1_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 INTERFAZ_1 (see VARARGIN)

% Choose default command line output for INTERFAZ_1
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes INTERFAZ_1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = INTERFAZ_1_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 NOMBRE_Callback(hObject, eventdata, handles)
val=get(hObject, 'string');
% hObject    handle to NOMBRE (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 NOMBRE as text
%        str2double(get(hObject,'String')) returns contents of NOMBRE as a double


% --- Executes during object creation, after setting all properties.
function NOMBRE_CreateFcn(hObject, eventdata, handles)
% hObject    handle to NOMBRE (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 PATERNO_Callback(hObject, eventdata, handles)
val=get(hObject, 'string');
% hObject    handle to PATERNO (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 PATERNO as text
%        str2double(get(hObject,'String')) returns contents of PATERNO as a double


% --- Executes during object creation, after setting all properties.
function PATERNO_CreateFcn(hObject, eventdata, handles)
% hObject    handle to PATERNO (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 MATERNO_Callback(hObject, eventdata, handles)
val=get(hObject, 'string');
% hObject    handle to MATERNO (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 MATERNO as text
%        str2double(get(hObject,'String')) returns contents of MATERNO as a double


% --- Executes during object creation, after setting all properties.
function MATERNO_CreateFcn(hObject, eventdata, handles)
% hObject    handle to MATERNO (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 GUARDAR.
function GUARDAR_Callback(hObject, eventdata, handles)
opc=questdlg({'Verifique que sus datos sean correctos.', 'Una vez guardados no podran modificarse.',' ', '¿Son correctos sus datos?'}, '¡ESPERE UN MOMENTO!', '', 'No', 'Si');
if strcmp(opc, 'No')
    return;
else strcmp(opc, '')
    for n=1:10
   usuario(n)= struct('Nombre', val,'Apellido paterno', val, 'Apellido materno', val)
    end
end
% hObject    handle to GUARDAR (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in GRABAR.
function GRABAR_Callback(hObject, eventdata, handles)
    opcion=questdlg({'Elija una palabra secreta despues hable fuerte y claro durante el proceso de grabación.','La grabación comenzará inmediatamente despues que de click en "Sí".','','¿Esta usted listo para grabar?'},'¡AVISO!', '', 'No', '');
if strcmp(opcion, 'No')
    return;
else strcmp(opcion, '')
    clear all;
    fun_GRABAR;
end
delete(hObject)

% hObject    handle to GRABAR (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in BORRAR.
function BORRAR_Callback(hObject, eventdata, handles)
clear all;
% hObject    handle to BORRAR (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in GUARDAR_VOZ.
function GUARDAR_VOZ_Callback(hObject, eventdata, handles)
Nombres.voz=get(handles.voz, 'string');
save('Nombres.mat', 'Nombres');


% hObject    handle to GUARDAR_VOZ (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de JOSE JEREMIAS CABALLERO
Val: 6.975
Oro
Ha mantenido su posición en Matlab (en relación al último mes)
Gráfica de Matlab

estructuras en matlab

Publicado por JOSE JEREMIAS CABALLERO (5917 intervenciones) el 30/11/2014 14:54:19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
function varargout = INTERFAZ_1(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @INTERFAZ_1_OpeningFcn, ...
                   'gui_OutputFcn',  @INTERFAZ_1_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
 
function INTERFAZ_1_OpeningFcn(hObject, eventdata, handles, varargin)
global n
n=1;
handles.output = hObject;
guidata(hObject, handles);
 
function varargout = INTERFAZ_1_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
 
function NOMBRE_Callback(hObject, eventdata, handles)
val=get(hObject, 'string');
 
function PATERNO_Callback(hObject, eventdata, handles)
val=get(hObject, 'string');
 
function MATERNO_Callback(hObject, eventdata, handles)
val=get(hObject, 'string');
 
function GUARDAR_Callback(hObject, eventdata, handles)
global n
opc=questdlg({'Verifique que sus datos sean correctos.', ...
    'Una vez guardados no podran modificarse.',' ',...
    '¿Son correctos sus datos?'}, '¡ESPERE UN MOMENTO!', 'Sí', 'No', 'Si');
if strcmp(opc,'No')
    return;
else strcmp(opc,'Sí')
    usuario(n)= struct('Nombre', val,'Apellido paterno', val, 'Apellido materno', val)
    n=n+1;
end
 
function GRABAR_Callback(hObject, eventdata, handles)
    opcion=questdlg({'Elija una palabra secreta despues hable fuerte y claro durante el proceso de grabación.',...
        'La grabación comenzará inmediatamente despues que de click en "Sí".',...
        '','¿Esta usted listo para grabar?'},'¡AVISO!', 'Sí', 'No', 'Sí');
if strcmp(opcion, 'No')
    return;
else strcmp(opcion, 'Sí')
    clear all;
    fun_GRABAR;
end
delete(hObject)
 
function BORRAR_Callback(hObject, eventdata, handles)
clear all;
 
function GUARDAR_VOZ_Callback(hObject, eventdata, handles)
Nombres.voz=get(handles.voz, 'string');
save('Nombres.mat', 'Nombres');
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

estructuras en matlab

Publicado por FELIPE (4 intervenciones) el 05/12/2014 18:50:58
Disculpa estuve fuera unos dias y no habia podido verificar tus respuestas, implemente la parte del codigo que me proporcionaste en el que 'n' es una variable global aun así arroja un error al momento de guardar.
Subo los archivos .fig y .m. Gracias!!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar