看板 MATLAB 關於我們 聯絡資訊
不好意思,請教一下, 我用MATLAB寫一個function要輸出txt檔, 可是好像不行,有人可以給建議嗎? ------ function Output_Data = output_txt_data( file_title, inputdata ) % file_title 是要輸出的檔案之檔名 % 要輸出的內容(數值) fid = fopen('file_title','wt'); [ m, n ] = size(inputdata); for i = 1 : 1 : m for j = 1 : 1 : n if j == 1 fprintf(fid, '%9.0f', inputdata(i, j)); elseif j == n fprintf(fid, '%6.4f\n', inputdata(i,j)); else fprintf(fid, '%9.4f\t\r', inputdata(i,j)); end end end fclose(fid); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.238.117.86 ※ 文章網址: https://www.ptt.cc/bbs/MATLAB/M.1466754395.A.39B.html
name0625: fid = fopen([file_title '.txt'],'wt'); 這樣試試看? 06/24 16:29
netsm: 不行ㄟ... 06/25 02:03
name0625: 我自己用是可以,你的不行是怎樣不行? 06/25 08:11
x46824682x: 錯誤碼貼出來吧..這應該很簡單... 06/25 10:37
netsm: Output argument "Output_Data" (and maybe others) not as 06/25 20:08
netsm: not assigned during call to "output_txt_data". 06/25 20:09
celestialgod: fopen('file_title','wt');改成fopen(file_title,'w 06/25 20:59
celestialgod: t'); 06/25 20:59
celestialgod: function Output_Data = output_txt_data( file_tit 06/25 21:01
celestialgod: le, inputdata ) 改成 function [] = output_txt_da 06/25 21:01
celestialgod: ta( file_title, inputdata ) 06/25 21:01
netsm: 感謝以上各位高手熱心地回覆,我試出來了,謝謝... 06/30 15:17
netsm: 改成... 06/30 15:18
netsm: function output_txt_data( filename, inputdata ) 06/30 15:19
netsm: fid = fopen([filename '.txt'],'wt'); 06/30 15:20
netsm: 特別感謝一樓的大大,你的提示是對的,可是我忘了改第1行.. 06/30 15:22