作者littledou (o o )
看板MATLAB
標題[問題] txt檔案輸出問題
時間Sat May 19 17:57:31 2012
我在主視窗中輸入
x = 1:10;
y = [x; sqrt(x)];
fid = fopen('sqrt.dat', 'w');
fprintf(fid, 'Table of square root:\n');
fprintf(fid, '%2.0f => %10.6f\n',y);
fclose(fid);
type sqrt.dat (源自 張智星 書本)
錯誤顯示:
??? Error using ==> fprintf
Invalid file identifier. Use fopen to generate a valid file
identifier.
試過許多例子,都會有這樣的問題,請問該如何解決?
謝謝!!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.96.135
1F:→ Steven0422:fopen失敗 看一下fid的值 05/19 18:50
2F:→ littledou:測試出來是-1 請問 那個檔案室原本就要存在嗎 05/20 04:05
3F:推 brettchen:我照你的打沒事,路徑中有中文嗎? 05/20 06:00
4F:→ brettchen:版本2010b 05/20 06:01
5F:推 vincent59:我測試過也ok阿 05/20 12:05
6F:→ littledou:我的資料夾中有中文~~ 我試著換成英文看看 05/20 12:52
7F:→ littledou:後來發現是路徑執行位置的問題 已經解決 謝謝大家 05/20 20:09