Saving multiple responses from a single edit text box
Mostrar comentarios más antiguos
I am trying to save multiple responses from a single edit text box each time the user pushes a "save" button. Below is my code:
function pushbutton1_Callback(hObject, eventdata, handles)
s = get(handles.edit1, 'String');
output_s = fopen('GUIDATA.txt','a');
formatspec = '%s';
fprintf(output_s,'%s',s);
fclose(output_s);
end
I'm getting a .txt file with a long string of the responses, but I'd like to eventually have a list of words that the user will hear in the first column, and the user input be saved in the second column, something like this
Target word User response
hello <user input from edit text box>
wall <user input from edit text box>
Thanks for any help in advance. I'm fairly new to Matlab and just can't seem to figure this out.
Respuesta aceptada
Más respuestas (1)
HUSNU CANBOLAT
el 29 de Dic. de 2019
ca={handles.text_bilgiler} ;
str = char(ca);
fid = fopen(strcat('test.txt'), 'w');
formatSpec = '%s\n';
[nrows,ncols] = size(str);
for row = 1:nrows
fprintf(fid,formatSpec,str(row,:));
end
fclose(fid);
Categorías
Más información sobre Standard File Formats en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!