Re: [問題] 跑回圈存圖檔已回收

看板MATLAB作者 (神無月 孝臣)時間13年前 (2011/07/08 11:13), 編輯推噓5(506)
留言11則, 3人參與, 最新討論串2/2 (看更多)
※ 引述《snaredrum (好聽木琴)》之銘言: : 不好意思 新手發問,雖然爬過文,可是看不太懂.. : 我想要跑完回圈 存圖檔案.. : ex: : for n=1:30 : for i=1:100 : a(i)=xxxx : y(i)=#### : ...... : ...... : end : plot(a,y) : end : 結果出來就只有一張圖 就是n=30那張... : 我想要對每個給定的n 就畫出依張圖 所以會有30張, : 那我希望檔名可以存成 n1,n2,n3... n30 這該如何做呢? : 還有 看過 圖片上方就寫 n=1, : 我想在n1圖片上方打上n=1 那該如何做呢? 30張 都想這樣子打又該如何打呢? : 感謝前輩賜教... h = figure( 1 ) ; set( h , 'Visible' , 'off' ) <=加速用,可有可無 for n=1:30 clf for i=1:100 a(i)=xxxx y(i)=#### ...... ...... end plot(a,y) title( [ 'n=' , num2str( n ) ] ) saveas( h , [ 'n' , num2str( n ) , '.png' ] ) end 先幫你存成png 我自己經驗是太大張圖用bmp來存的話 會說記憶體不足 存成png倒是沒這個問題 -- On the surface, your parents sought a private life, using their great talents to provide for you. They learned to twist the lies of church and government, believing themselves masters of the system. But the parasites say "NO! The child has a duty! He'll go to war and die for the nation." ─Andrew Ryan -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.120.24.116

07/08 11:15, , 1F
感謝回應... ^_^
07/08 11:15, 1F

07/08 11:15, , 2F
我看依下我之前存的檔案都是fig 看起來檔案不大
07/08 11:15, 2F

07/08 11:15, , 3F
png 跟fig差別在哪阿 ?
07/08 11:15, 3F

07/08 11:33, , 4F
跑完了 .png 很漂亮耶.. thanks..
07/08 11:33, 4F

07/08 14:24, , 5F
fig是matlab圖片儲存格式,不是圖片檔案
07/08 14:24, 5F

07/08 14:25, , 6F
你還可以從fig裡面把原始繪圖data挖出來
07/08 14:25, 6F

07/08 23:23, , 7F
受教了...感激耶...
07/08 23:23, 7F

07/09 00:14, , 8F
那我如果把上敘的.npg 改成.fig那圖檔是不是就一值被覆?
07/09 00:14, 8F

07/09 00:15, , 9F
因為變數都是a跟y,迴圈跑他就一直被覆蓋..
07/09 00:15, 9F

07/09 07:57, , 10F
不會,num2str(n)是從1~30, 所以每個迴圈都會存成一個新的檔
07/09 07:57, 10F

07/09 07:57, , 11F
但是a和y會被蓋掉沒錯
07/09 07:57, 11F
文章代碼(AID): #1E5dNCL2 (MATLAB)
文章代碼(AID): #1E5dNCL2 (MATLAB)