Matlab基本函数-compass函数
1、compass函数:罗盘图
2、用法说明:
(1)compass(x,y)函数绘制一个由原点出发由(x,y)组成的向量箭头图形;
(2)compass(z)等价于compass(real(z),imag(z));
(3)compass(...,LineSpec)函数用参量LineSpec指定箭头的线型、标记符号、颜色等属性;
(4)h = compass(...)函数返回line对象的句柄给h。
3、实例
3.1、compass(x,y)
(1)源码
>> x=1:100
x =
Columns 1 through 17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Columns 18 through 34
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Columns 35 through 51
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
Columns 52 through 68
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
Columns 69 through 85
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
Columns 86 through 100
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
>> y=rand(1,100)
y =
Columns 1 through 10
0.8147 0.9058 0.1270 0.9134 0.6324 0.0975 0.2785 0.5469 0.9575 0.9649
Columns 11 through 20
0.1576 0.9706 0.9572 0.4854 0.8003 0.1419 0.4218 0.9157 0.7922 0.9595
Columns 21 through 30
0.6557 0.0357 0.8491 0.9340 0.6787 0.7577 0.7431 0.3922 0.6555 0.1712
Columns 31 through 40
0.7060 0.0318 0.2769 0.0462 0.0971 0.8235 0.6948 0.3171 0.9502 0.0344
Columns 41 through 50
0.4387 0.3816 0.7655 0.7952 0.1869 0.4898 0.4456 0.6463 0.7094 0.7547
Columns 51 through 60
0.2760 0.6797 0.6551 0.1626 0.1190 0.4984 0.9597 0.3404 0.5853 0.2238
Columns 61 through 70
0.7513 0.2551 0.5060 0.6991 0.8909 0.9593 0.5472 0.1386 0.1493 0.2575
Columns 71 through 80
0.8407 0.2543 0.8143 0.2435 0.9293 0.3500 0.1966 0.2511 0.6160 0.4733
Columns 81 through 90
0.3517 0.8308 0.5853 0.5497 0.9172 0.2858 0.7572 0.7537 0.3804 0.5678
Columns 91 through 100
0.0759 0.0540 0.5308 0.7792 0.9340 0.1299 0.5688 0.4694 0.0119 0.3371
>> compass(x,y)
(2)运行结果
3.2、compass(z)
(1)源码
>> z=[1+2i 2+4i 5-6i]
z =
1.0000 + 2.0000i 2.0000 + 4.0000i 5.0000 - 6.0000i
>> compass(z)
(2)结果
3.3、compass(...,LineSpec)
(1)源码
compass(x,y,'--m')
(2)结果
3.4、h = compass(...)
(1)源码
>> h=compass(x,y,'--m')
h =
199.0013
200.0013
201.0013
202.0013
203.0013
204.0013
205.0013
206.0013
207.0013
208.0013
209.0013
210.0013
211.0013
212.0013
213.0013
214.0013
215.0013
216.0013
217.0013
218.0013
219.0013
220.0013
221.0013
222.0013
223.0013
224.0013
225.0013
226.0013
227.0013
228.0013
229.0013
230.0013
231.0013
232.0013
233.0013
234.0013
235.0013
236.0013
237.0013
238.0013
239.0013
240.0013
241.0013
242.0013
243.0013
244.0013
245.0013
246.0013
247.0013
248.0013
249.0013
250.0013
251.0013
252.0013
253.0013
254.0013
255.0013
256.0013
257.0013
258.0013
259.0013
260.0013
261.0013
262.0013
263.0013
264.0013
265.0013
266.0013
267.0013
268.0013
269.0013
270.0013
271.0013
272.0013
273.0013
274.0013
275.0013
276.0013
277.0013
278.0013
279.0013
280.0013
281.0013
282.0013
283.0013
284.0013
285.0013
286.0013
287.0013
288.0013
289.0013
290.0013
291.0013
292.0013
293.0013
294.0013
295.0013
296.0013
297.0013
298.0013