星期五, 12月 01, 2006

work9

r95631002 黃聖峰 作業9

What's difference between the commands "line" and "plot", explain by using your own examples.




(1)第一個不同,plot不能一次畫二個圖,因為它會覆蓋第一個圖,必須要用hold on來保持住第一個圖或是用plot(x,y,x,y1)也可以

(2)第二個不同,要是想更改line的顏色和型式,line不能直接在後面接'顏色的代碼'和'型式的代碼'(plot的代碼應用的比較多),要用屬性名稱才能加其代碼

注意一下,要是在程式碼改其'顏色'或'型式'要是一打錯其屬性名稱,則程式就會不會畫出圖.

最好是用set 指令來改變會比較好

程式碼
clear all
close all
clc

x=0:500;x1=500:1000;
y=0.25*exp(-0.05*x);
y1=0.5*exp(-0.05*x);

figure(1);line(x,y)
line(x1,y1,'color','r','linestyle','+') % 必須要用出屬性名稱才能加其代碼
xlabel('x軸')
ylabel('y軸')

figure(2)
hold on % 利用hold on
plot(x,y)
plot(x1,y1,'r*') % 直接用代碼
xlabel('x軸')
ylabel('y軸')
hold off

figure(3)
plot(x,y,x1,y1) % 用plot它每一條線條都會有不同的顏色

1 則留言:

ncbee 提到...

r95631002 黃聖峰 作業9
What's difference between the commands "line" and "plot", explain by using your own examples.
(1)第一個不同,plot不能一次畫二個圖,因為它會覆蓋第一個圖,必須要用hold on來保持住第一個圖或是用plot(x,y,x,y1)也可以

(2)第二個不同,要是想更改line的顏色和型式,line不能直接在後面接'顏色的代碼'和'型式的代碼'(plot的代碼應用的比較多),要用屬性名稱才能加其代碼

注意一下,要是在程式碼改其'顏色'或'型式'要是一打錯其屬性名稱,則程式就會不會畫出圖.

最好是用set 指令來改變會比較好

程式碼
clear all
close all
clc

x=0:500;x1=500:1000;
y=0.25*exp(-0.05*x);
y1=0.5*exp(-0.05*x);

figure(1);line(x,y)
line(x1,y1,'color','r','linestyle','+') % 必須要用出屬性名稱才能加其代碼
xlabel('x軸')
ylabel('y軸')
圖片一
figure(2)
hold on % 利用hold on
plot(x,y)
plot(x1,y1,'r*') % 直接用代碼
xlabel('x軸')
ylabel('y軸')
hold off
圖片二
figure(3)
plot(x,y,x1,y1) % 用plot它每一條線條都會有不同的顏色
圖片三

花蓮的海豚

花蓮的海豚