Save from listbox to txt file

1 Ansicht (letzte 30 Tage)
Adi Mico
Adi Mico am 10 Aug. 2011
Beantwortet: Walter Roberson am 20 Apr. 2018
I have the code to save the string from listbox into txtfile
function save_Callback(hObject, eventdata, handles)
fID=fopen('coba.txt','w');
kata=get(handles.listbox,'String');
for ii=1:numel(kata)
fprintf(fID,'%s\n',kata{ii});
end
fclose(fID);
The result in coba.txt is like this
a as asas
How can I edit so the result is like this
a
as
asas
I thought if I give '\n' I'll get the result I want but it's not working. please help me.

Antworten (2)

Veera Kanmani
Veera Kanmani am 20 Apr. 2018
https://in.mathworks.com/matlabcentral/answers/290362-how-to-save-gui-s-listbox-content-to-a-text-file-or-excel-file

Walter Roberson
Walter Roberson am 20 Apr. 2018
Open with 'wt' instead of 'w'

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by