Escolar Documentos
Profissional Documentos
Cultura Documentos
N. MARTINS-FERREIRA
50 % returns
51 c1 = [ 1 2 4 5 6 7 8 9 ]
52 i a 1 = [ 2 1 20 19 18 16 13 10 6 ]
53 ic1 = [8 8 8 8 8 8 7 7 7 7 6 6 6 5 5 5 4 4 3
2 1]
54
55 [ c2 , i a 2 , i c 2 ] = unique ( a , ’ s t a b l e ’ )
56 % returns
57 c2 = [ 9 8 7 6 5 4 2 1 ]
58 i a 2 = [ 1 7 11 14 17 19 20 2 1 ] ’
59 ic2 = [1 1 1 1 1 1 2 2 2 2 3 3 3 4 4 4 5 5 6
7 8] ’
60
61 c = unique ( [ 1 NaN NaN 2 ] )
62 % NaNs compare as not e q u a l , so t h i s r e t u r n s
63 c = [ 1 2 NaN NaN]
64
65 C l a s s s u p p o r t f o r input A:
66 − l o g i c a l , char , a l l numeric c l a s s e s
67 − c e l l arrays of strings
68 −− ’ rows ’ o p t i o n i s not s u p p o r t e d f o r c e l l
arrays
69 − o b j e c t s with methods SORT (SORTROWS f o r t h e
’ rows ’ o p t i o n ) and NE
70 −− i n c l u d i n g h e t e r o g e n e o u s a r r a y s
71
72 See a l s o union , i n t e r s e c t , s e t d i f f , s e t x o r ,
ismember , sort , s o r t r o w s .
n
A >
R
s
t u
B
tal que us = f , ut = g e u é uma função injetiva.
A implementação deve ter a seguinte assinatura:
1 function [ s , t , u]= d i g r a p h ( s o u r c e , t a r g e t )
28 dirA=gphiA−gA ; midA=(gA+gphiA ) / 2 ;
29 x=r e a l (gA) ; y=imag (gA) ;
30 u=r e a l ( dirA ) ; v=imag ( dirA ) ;
31 h=quiver ( x , y , u , v , 0 ) ;
32
33 %
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
41 % t h i s code i s o n l y e x e c u t e d i f 5=3+2 p a r a m e t e r s a r e
entered
42 i f nargin > 4
43 v=v a r a r g i n { 2 } ;
44 c e n t e r=g ( p h i (A ( : ) ) ) ;
45 incom=g (A ( : ) )−c e n t e r ;
46 outcom=g ( p h i ( p h i (A ( : ) ) ) )−c e n t e r ;
47 r a d i u s=v∗mean( abs ( [ incom ( : ) ; outcom ( : ) ] ) ) ;
48 a n g b e g i n=angle ( incom ) ; % where t h e a n g l e b e g i n s
49 ang amp=angle ( outcom . / incom ) ; % a m p l i t u d e
50 ang amp ( ang amp <0)=ang amp ( ang amp <0)+2∗pi ; %
transform in [0 2 pi [
51 dg =(( ang amp/ pi ) ∗ 1 8 0 ) ; % t r a n s f o r m s i n t o d e g r e e s
t i m e s 10 (0−−36) i n s t e a d o f (0−−360)
52 disp ( [ A ( : ) , a n g b e g i n ( : ) , ang amp ( : ) , dg ( : ) ] )
53 dg=round ( dg ) ;
54 hold on
55 % p l o t a n g l e s ( as a r c w i t h r a t i u s v − t h e e n t e r e d
parameter ) a t t a c c h e d t o e v e r y arrow and i t s
s u c c e s i v e arrow
56 f o r j =1: numel (A)
57 z0=c e n t e r ( j ) ;
58 t=linspace ( 0 , 1 , abs ( dg ( j ) ) / 1 0 ) ;
59 a n g p o i n t s=r a d i u s ∗exp ( ( t ∗ ( ang amp ( j ) )+a n g b e g i n ( j )
) ∗ sqrt ( −1) ) ;
60 plot ( z0+a n g p o i n t s , ’ . ’ )
61 i f abs ( dg ) >5,
62 tx=z0+a n g p o i n t s ( round ( ( ( end+1) / 2 ) ) ) ; %c e n t e r+
v ∗ exp ( ( 0 . 5 ∗ ( ang amp )+a n g b e g i n ) ∗ s q r t (−1) ) ;
63 text ( r e a l ( tx ) , imag ( tx ) , num2str ( dg ( j ) ) )
64 end
65 end
66 axis e q u a l
67 hold o f f
6 N. MARTINS-FERREIRA
68 end
3 %
4 %
5 % Example :
6 % n=20 , k =7, ck =2, pk =2,
7 % [ phi , orb , ord , p s i ]= o r b i t s g e n ( n , k , ck , pk ) ;
8
9 >> disp ( [ ( 1 : 2 0 ) ’ p h i orb ord p s i ] )
10 1 2 −1 1 0
11 2 3 −1 2 1
12 3 4 −1 3 2
13 4 3 −1 Inf 3
14 5 6 −2 1 0
15 6 7 −2 2 5
16 7 8 −2 3 6
17 8 8 −2 Inf 7
18 9 10 −3 1 0
19 10 11 −3 2 9
20 11 12 −3 3 10
21 12 8 −3 −2 11
22 13 14 −4 1 0
23 14 15 −4 2 13
24 15 2 −4 −1 14
25 16 17 −5 1 0
26 17 8 −5 −2 16
27 18 18 1 1 18
28 19 20 2 1 20
29 20 19 2 2 19
g
ϕ A / (4)
7 C