>> t=[0:0.01:0.98]; >> y1 = sin(2*pi*4*t); >> plot(t,y1);
>> y2 = cos(2*pi*4*t); >> plot(t,y2);
>> plot(t,y1); >> hold on; %覆蓋 >> plot(t,y2,'r'); %y2使用紅色線條
加上橫縱坐標值:
>> xlabel('time') %坐標值 >> ylabel('value')
>> legend('sin', 'cos') %標記曲線
>> title('plot') %標題
保存圖片:
>> cd 'F:' >> pwd ans = F:\ >> print -dpng 'myPlot.png'
關閉繪制:
>> close
同時繪制(不同窗口);
>> figure(1); plot(t,y1); >> figure(2); plot(t,y2);
(同窗口):
>> subplot(1,2,1); %制造一個1*2的格子窗口,接下來在第一個窗口繪制 >> plot(t,y1); >> subplot(1,2,2); %在第二個窗口繪制 >> plot(t,y2);
改變刻度:
>> axis([0.5 1 -1 1]) %橫坐標0.5~1,縱坐標-1~1
清除繪圖:
>> clf;
繪制矩陣:
>> A = magic(5)
A =
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
>> iamgesc(A)
>> imagesc(A),colorbar, colormap gray; %同時執行三條命令
右邊是顏色的值,對應矩陣圖元素的值,如A(1,1)的值是17,則坐標(1,1)的顏色對應右邊17的顏色值。