Lab1

14
24 มีนาคม 2559 (Week 1) 1.การพล็อตกราฟ 1 เส้น การพล็อตกราฟ ใช้คําสั่ง x = [4 7 16]; y = [1 2 3]; plot (x,y) กด Enter ผลจะปรากฏตามรูป

Transcript of Lab1

Page 1: Lab1

24 มีนาคม 2559 (Week 1)

1.การพลอ็ตกราฟ 1 เส้น

การพลอ็ตกราฟ

ใช้คาํส่ัง

x = [4 7 16];

y = [1 2 3];

plot (x,y)

กด Enter

ผลจะปรากฏตามรูป

Page 2: Lab1

การตั้งช่ือกราฟ

ใช้คาํส่ัง

x = [4 7 16];

y = [1 2 3];

plot (x,y)

title(‘score of crassroom’)

กด Enter

ผลจะปรากฏตามรูป

Page 3: Lab1

ตั้งช่ือแกน X และแกน Y

ใช้คาํส่ัง

x = [4 7 16];

y = [1 2 3];

plot (x,y)

title(‘score of crassroom’)

xlable(‘crassroom’)

ylable(‘score’)

กด Enter

ผลจะปรากฏตามรูป

Page 4: Lab1

ลกัษณะเส้นกราฟ

เปล่ียนเส้นกราฟเป็นสีแดง

สีทีใ่ช้ในการเปลีย่นเส้น มี สีแดง (Red), สีเขียว (Green), สีเหลือง (Yellow), สีนํ้าเงิน (Blue), สีดาํ (K)

ใช้คาํส่ัง

x = [4 7 16];

y = [1 2 3];

plot (x,y)

title(‘score of crassroom’)

xlable(‘crassroom’)

ylable(‘score’)

plot(x,y,’red’)

กด Enter

ผลจะปรากฏตามรูป

Page 5: Lab1

เปล่ียนเส้นกราฟเป็นเส้นปะ

การทํากราฟให้เป็นเส้นปะ ใช้ (- -)

ใช้คาํส่ัง

x = [4 7 16];

y = [1 2 3];

plot (x,y)

title(‘score of crassroom’)

xlable(‘crassroom’)

ylable(‘score’)

plot(x,y,’red’)

plot(x,y,’—r’)

กด Enter

ผลจะปรากฏตามรูป

Page 6: Lab1

เปล่ียนเส้นกราฟเป็นเส้นปะสลบักบัจุด

ใช้คาํส่ัง

x = [4 7 16];

y = [1 2 3];

plot (x,y)

title(‘score of crassroom’)

xlable(‘crassroom’)

ylable(‘score’)

plot(x,y,’red’)

plot(x,y,’--r’)

plot(x,y,’-.r’)

กด Enter

ผลจะปรากฏตามรูป

Page 7: Lab1

เปล่ียนเส้นกราฟเป็นเส้นปะสลบัเคร่ืองหมายบวก

ใช้คาํส่ัง

x = [4 7 16];

y = [1 2 3];

plot (x,y)

title(‘score of crassroom’)

xlable(‘crassroom’)

ylable(‘score’)

plot(x,y,’red’)

plot(x,y,’--r’)

plot(x,y,’-.r’)

plot(x,y,’-+r’)

กด Enter

ผลจะปรากฏตามรูป

Page 8: Lab1

เปล่ียนเส้นกราฟเป็นเส้นปะสลบัวงกลม

ใช้คาํส่ัง

x = [4 7 16];

y = [1 2 3];

plot (x,y)

title(‘score of crassroom’)

xlable(‘crassroom’)

ylable(‘score’)

plot(x,y,’red’)

plot(x,y,’--r’)

plot(x,y,’-.r’)

plot(x,y,’-+r’)

plot(x,y,’-or’)

กด Enter

ผลจะปรากฏตามรูป

Page 9: Lab1

2) การพลอ็ตกราฟ 3 เส้น

พลอ็ตกราฟ 3 เส้น

ใช้คาํส่ัง

x = [2 5 9 10 21];

y = [3 9 5 11 13];

z = [4 6 9 3 21];

t = [3 4 5 6 7];

plot(x,t,’—r’,y,t,’-.b’,z,t,’-^k’)

กด Enter

ผลจะปรากฏตามรูป

Page 10: Lab1

ใส่สญัลกัษณ์และความหมายสัญลกัษณ์ (แต่สญัลกัษณ์ยงับงัขอ้มูลอยู)่

สัญลกัษณ์ (Legend) ไดแ้ก่ เคร่ืองบิน = สีแดง (r), รถไฟ = สีนํ้ าเงิน (b), เรือ = สีดาํ (k)

ใช้คาํส่ัง

x = [2 5 9 10 21];

y = [3 9 5 11 13];

z = [4 6 9 3 21];

t = [3 4 5 6 7];

plot(x,t,’—r’,y,t,’-.b’,z,t,’-^k’)

legend(‘airplane’,’train’,’ship’)

กด Enter

ผลจะปรากฏตามรูป

Page 11: Lab1

กราฟของเคร่ืองบิน

เคร่ืองบิน = สีแดง (r)

ใช้คาํส่ัง

x = [2 5 9 10 21];

y = [3 9 5 11 13];

z = [4 6 9 3 21];

t = [3 4 5 6 7];

plot(x,t,’--r’,y,t,’-.b’,z,t,’-^k’)

legend(‘airplane’,’train’,’ship’)

legend(‘location’,’northwest’)

subplot(2,2,1)

plot(x,t,’--r’)

กด Enter

ผลจะปรากฏตามรูป

Page 12: Lab1

กราฟของรถไฟ

รถไฟ = สีนํา้เงิน (b)

ใช้คาํส่ัง

x = [2 5 9 10 21];

y = [3 9 5 11 13];

z = [4 6 9 3 21];

t = [3 4 5 6 7];

plot(x,t,’--r’,y,t,’-.b’,z,t,’-^k’)

legend(‘airplane’,’train’,’ship’)

legend(‘location’,’northwest’)

subplot(2,2,1)

plot(x,t,’--r’)

subplot(2,2,2)

plot(y,t,’-^k’)

กด Enter

ผลจะปรากฏตามรูป

Page 13: Lab1

กราฟเรือ

เรือ = สีดํา (k)

ใช้คาํส่ัง

x = [2 5 9 10 21];

y = [3 9 5 11 13];

z = [4 6 9 3 21];

t = [3 4 5 6 7];

plot(x,t,’--r’,y,t,’-.b’,z,t,’-^k’)

legend(‘airplane’,’train’,’ship’)

legend(‘location’,’northwest’)

subplot(2,2,1)

plot(x,t,’--r’)

subplot(2,2,2)

plot(y,t,’-^k’)

subplot(2,2,3)

Page 14: Lab1

plot(z,t,’-.b’)

กด Enter

ผลจะปรากฏตามรูป