Escribir archivos txt desde GUI
Publicado por Luisa (2 intervenciones) el 18/05/2018 19:50:21
Hola, tengo un problema y es que no se que estoy haciendo mal con mi codigo, lo que deseo hacer es abrir un archivo txt dado sea el caso y escribir en este la información que obtengo como de un formulario creado en una interface de GUI qeu contiene popupmenus, edit txt y static txt ... adjunto mi codigo para que sea más entendible lo que quiero hacer
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
function agregarpa2_Callback(hObject, eventdata, handles)
% hObject handle to agregarpa2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
estado=get(handles.popestadocivil,'Value');
nombres=get(handles.editnombre,'String');
genero=get(handles.popgenero,'Value');
dia=get(handles.popdia,'Value');
mes=get(handles.popmes,'Value');
ano=get(handles.popano,'Value');
hora=get(handles.edithora,'String');
raza=get(handles.popraza,'Value');
lenguaje=get(handles.poplenguaje,'Value');
porcentaje=get(handles.editpercent,'String');
global ide
id=ide;
apellidos=get(handles.editapellidos,'String');
[name path]=uigetfile({'*.txt'},'Seleccione un archivo');
fid=fopen(name,'w');
if name=='PatientCorePopulatedTable382.txt'
fprintf(fid,'%s %s %s - %s - %s %s : %s %s %s %s %s %s',id,genero,ano,mes,dia,hora,raza,estado,lenguaje,porcentaje);
else if name=='PatientOtherInformation382.txt'
fprintf(fid,'- - %s,%s - %s %s : %s %s %s %s %s %s',apellidos,nombres,id);
else
error('El archivo seleccionado es inválido');
end
fclose(fid);
end
Valora esta pregunta


0