フィルターのクリア

How to store datas from a GUI into a .txt file ?

3 ビュー (過去 30 日間)
CHAZAUD Mathilde
CHAZAUD Mathilde 2019 年 5 月 21 日
回答済み: Saumya Goel 2019 年 5 月 24 日
Hello !
I have GUI windows with several edit text boxes. I store all the inputs in arrays using these lines code:
x=getappdata(hObject,'x');
x(end+1)=str2double(handles.x(1).String);
handles.x(1).String=sprintf('block %d',numel(x)+1);
disp(x)
setappdata(hObject,'x',x);
assignin('base','x',x);
I want to write all the datas in one .txt file.
For example in my .txt I'd like something like:
x 0 10 15
y 10 20
z 20 25 30 40
K 0.5
I need a .txt file because the datas will be red by an other programm. It is a specific demand from my supervisor that the GUI generate a .txt file
How can I do that ?
I tried to wrtie in every edit text box's callback
fid = fopen('GUIDATA.txt','wt');
fprintf(fid,'%d',nx)
fclose(fid);
with
fid = fopen('GUIDATA.txt','r');
in the OpeningFcn of my GUI
But it does only save the last input...

回答 (1 件)

Saumya Goel
Saumya Goel 2019 年 5 月 24 日
I believe the issue is that you have set the permission as "w" that is every time create a new file or overwrite the contents of exisitng file. You can try setting the permission to "Append". This will append the data to existing file and hence not overwrite the content on the file.
For more information, refer to this document: ("permission" section)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by