我想在某些特定文件夾的不同文件中定期寫入代碼輸出。我使用 代碼如下:寫入多個輸出文件matlab
for i=1:m
% some other things
if (mod(i,1000)==0)
y=[1:dx:n_x;c_initial.'];
fn = ['/home/alekhine' num2str(i) '.dat'];
fid=fopen(fn);
fprintf(fid,'%6.4f %12.8f\n',y);
fclose(fid);
end
end
但我從MATLAB收到錯誤如下
Error using ==> fprintf
Invalid file identifier. Use fopen to generate a valid file
identifier.
。代碼中有什麼錯誤?任何幫助將不勝感激。
它有助於發佈錯誤 – mathematician1975
你好像在'/ home/alekhine'之後缺少一個路徑分隔符。 – Thor
@ mathematician1975,謝謝你的指導。發佈了錯誤。 – alekhine