read the text file in matlab gui as same formate
3 ビュー (過去 30 日間)
古いコメントを表示
hi all, i write a code to call text file in edit text(matlab GUI).but not call as same format, if any changes in edit text and save in other text file, it does not save as same format. so, what i change in code to save and call as same format after applying the push bottom.
fid = fopen('IO_PROCESS.txt','r');
if fid~=-1 %if the file doesn't exist ignore the reading code
set(handles.edit1,'String',fscanf(fid,'%s'))
fclose(fid);
end
2 件のコメント
Jan
2018 年 5 月 2 日
The question is not clear. What kind of "format" do you mean? Can you post a relevant example?
回答 (1 件)
Jan
2018 年 5 月 2 日
I not sure, what the problem is. It would be helpful if you mention, which problem you observe.
Maybe fscanf(fid, '%s') imports the first lien only? Then:
Str = fileread('IO_PROCESS.txt');
CStr = splitstr(Str, '\n');
set(handles.edit1, 'String', CStr);
...
CStr = get(handles.edit1, 'String');
fid = fopen(FileName, 'w');
if fid == -1
error('Cannot open file: %s', FileName);
end
fprintf(fid, '%s\n', CStr{:});
fclose(fid);
6 件のコメント
参考
カテゴリ
Help Center および File Exchange で Environment and Settings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!