5
function [org_data] = file_manipulation(in_fname, txt_fname, mat_fname)
org_data = round(load(in_fname));
fid = fopen(txt_fname,'wt+');
student_id = '9900';
txt = [txt_fname ' : ' student_id '\nDate of creation:' datestr(now,'dd/mm/yyyy')];
fprintf(fid,'%s',txt);
end
而不是插入新行生成的文件是:寫入新行到文本文件在MATLAB
C:\w2\test1.txt : 9900\nDate of creation:30/05/2012
什麼是對我的代碼一點改進?
換句話說,\ n由sprintf函數家族解釋,而不是像其他相關語言那樣處於預處理器級別。 – Peter
MATLAB並沒有真正爲字符串操作設計.. – Ansari
對不起,我不明白 - 即使你不使用變量? (我只是編輯了答案,用雙引號替換雙引號)。 – Ansari