15.05.2015 Views

manual de introdução ao matlab - Escola Superior Náutica Infante D ...

manual de introdução ao matlab - Escola Superior Náutica Infante D ...

manual de introdução ao matlab - Escola Superior Náutica Infante D ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Na <strong>de</strong>finição <strong>de</strong> vectores um símbolo muito utilizado é o “ : ”. Aqui estão alguns exemplos<br />

da sua utilização.<br />

» x=1:5 % começa em 1 e termina em 5 com incrementos <strong>de</strong> 1<br />

x =<br />

1 2 3 4 5<br />

Se preten<strong>de</strong>rmos utilizar um incremento diferente fazemos:<br />

» y=0:pi/4:pi % começa em 0 e termina em pi com incrementos <strong>de</strong> pi/4<br />

y =<br />

0 0.7854 1.5708 2.3562 3.1416<br />

Também é possível utilizar incrementos negativos:<br />

» z=6:-1:1<br />

z =<br />

6 5 4 3 2 1<br />

Outra maneira <strong>de</strong> <strong>de</strong>finir o vector y=sin(x) é a seguinte.<br />

» y1=(0:0.1:1)*pi<br />

y1 =<br />

Columns 1 through 7<br />

0 0.3142 0.6283 0.9425 1.2566 1.5708 1.8850<br />

Columns 8 through 11<br />

2.1991 2.5133 2.8274 3.1416<br />

Existem duas funções que po<strong>de</strong>mos utilizar para criar vectores.<br />

» l=linspace(0,pi,11)<br />

l =<br />

Columns 1 through 7<br />

0 0.3142 0.6283 0.9425 1.2566 1.5708 1.8850<br />

Columns 8 through 11<br />

2.1991 2.5133 2.8274 3.1416<br />

» g=logspace(0,2,11)<br />

g =<br />

Columns 1 through 7<br />

1.0000 1.5849 2.5119 3.9811 6.3096 10.0000 15.8489<br />

Columns 8 through 11<br />

ENIDH/DMM – Luis M. Mendonça<br />

Pág.21

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!