MatLab---基本繪圖功能(下)+資料的儲存和讀取(上)
一、grid on 與 grid off
gird on 顯示網格
gird off 關閉網格顯示
二、legend() 顯示圖示
legend('Line 1','Line 2')
三、繪製柱狀圖
bar(1:10,randi([1,10],[1,10]))
四、資料的儲存和讀取
1.儲存資料
maybat1=rand(4,3)
maybat1 =
0.9595 0.9340 0.3922
0.6557 0.6787 0.6555
0.0357 0.7577 0.1712
0.8491 0.7431 0.7060
save testfile.dat maybat1 -ascii
>> type testfile.dat
9.5949243e-01 9.3399325e-01 3.9222702e-01
6.5574070e-01 6.7873515e-01 6.5547789e-01
3.5711679e-02 7.5774013e-01 1.7118669e-01
8.4912931e-01 7.4313247e-01 7.0604609e-01
2.資料的追加
無論矩陣的行列是否相同,都可以追加
mybat2=rand(5,4)
mybat2 =
0.0318 0.6948 0.3816 0.4456
0.2769 0.3171 0.7655 0.6463
0.0462 0.9502 0.7952 0.7094
0.0971 0.0344 0.1869 0.7547
0.8235 0.4387 0.4898 0.2760
save testfile.dat mybat2 -ascii -append
3.資料的讀取
load testfile1.dat load 檔名
>> testfile1
testfile1 =
68 12 35 76 70
66 50 59 26 90
17 96 23 51 96
>> %讀取檔案之後,檔名當作變數名使用;