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.

回答 (2 件)

Veera Kanmani
Veera Kanmani 2018 年 4 月 20 日

0 投票

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 2018 年 4 月 20 日

0 投票

Open with 'wt' instead of 'w'

カテゴリ

ヘルプ センター および File ExchangeInteractive Control and Callbacks についてさらに検索

質問済み:

2011 年 8 月 10 日

回答済み:

2018 年 4 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by