作业帮 > 数学 > 作业

如何在matlab实现离散点画图

来源:学生作业帮 编辑:作业帮 分类:数学作业 时间:2024/05/07 19:52:08
如何在matlab实现离散点画图
位置点 X坐标(米) Y坐标(米)
1 9185 500
2 1445 560
3 7270 570
4 3735 670
5 2620 995
6 10080 1435
7 10025 2280
8 7160 2525
9 13845 2680
10 11935 3050
11 7850 3545
12 6585 4185
13 7630 5200
14 13405 5325
15 2125 5975
16 15365 7045
17 14165 7385
18 8825 8075
19 5855 8165
20 780 8355
21 12770 8560
22 2200 8835
23 14765 9055
24 7790 9330
25 4435 9525
26 10860 9635
27 10385 10500
28 565 9765
29 2580 9865
30 1565 9955
31 9395 10100
32 14835 10365
33 1250 10900
34 7280 11065
35 15305 11375
36 12390 11415
37 6410 11510
38 13915 11610
39 9510 12050
40 8345 12300
41 4930 13650
42 13265 14145
43 14180 14215
44 3030 15060
45 10915 14235
46 2330 14500
47 7735 14550
48 885 14880
49 11575 15160
50 8010 15325
解决方法
1 利用scatter函数画散点图
2 plot(x,y,'r.')
例子:
假如你有3个点:
No X Y
1 1 4
2 2 5
3 3 6
那么代码如下
x = [1 2 3]
y = [4 5 6]
plot(x,y,'r.')
figure
scatter(x,y)
在plot(x,y,'r.') 中的 r是指颜色为红色,.是指点的形状为的点状,也可以改成其它形状的,具体可以用matlab命令help plot查看
b blue .point - solid
g green o circle :dotted
r red x x-mark -.dashdot
c cyan + plus -- dashed
m magenta * star (none) no line
y yellow s square
k black d diamond
w white v triangle (down)
^ triangle (up)
< triangle (left)
> triangle (right)
p pentagram
h hexagram