1 / 6

# Matlab - PowerPoint PPT Presentation

Matlab. Generiranje podatkov. Matrike. Osnovne matrike eye (n) in eye (m, n) : identična matrika zeros (n) in zeros (m, n) : same ničle ones (n) in ones (m, n) : same enke rand (n) in rand (m,n) : matrika z naključnimi števili z [0,1)

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about ' Matlab' - kioko

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### Matlab

Generiranje podatkov

• Osnovne matrike

• eye(n) in eye(m, n) : identična matrika

• zeros(n) in zeros(m, n) : same ničle

• ones(n) in ones(m, n) : same enke

• rand(n) in rand(m,n) : matrika z naključnimi števili z [0,1)

• randi(doKam, n) in randi(doKam, n, m) : matrika z naključnimi celimi števili [1, doKam]

• Posebne matrike

• hilb(n) : hilbertova matrika (1, ½, 1/3 …)

• X = [od : korak : do]

• Vsa soda dvomestna števila

• X = [10 : 2 : 99]

• Števila od 10 do 0

• X = [10 : -1 : 0]

• X = [od : do]

• Isto kot x = [od:1:do]

• linspace(od, do, koliko)

• x = linspace(-pi, pi, 10) % 10 vrednosti od –Pi do Pi

• Isto kot x = [-pi : 2*pi/9 : pi]

• Matrika 10 x 10, ki ima na diagonali 1, 2, …, 10

• diagonala = [1:10]

• Matr = diag(diagonala)

• Vektor 5 metov kocke

• metiKocke = randi(6,1,5)

• Vektor 10 enakih metov kocke

• enakiMeti = randi(6) * ones(1,10)

• število op vektor

• Npr. 5 + [3, 4, 5, 2]

• Operacija se izvede po komponentah

• [1, 2, 3, 1] + [3, 4, 5, 2]

• [4, 6, 8, 3]

• [1, 2, 3, 1] * [3, 4, 5, 2]

• Napaka!

• [1, 2, 3, 1] .* [3, 4, 5, 2]

• Po komponentah

• [3, 8, 15, 2]

• Podobno pri matrikah: .op : operacija op se izvaja po komponentah

• Matematične funkcije nad vektorji in matrikami:

• sin, cos, …

• Izvajajo se po komponentah

• Tabeliraj funcijo sinus na intervalu [-pi, pi] s korakom pi/4

• x = [-pi : pi/4 : pi]

• vrednostiX = sin(x)

• size(M)

• dimenzija matrike

• Rezultat je vektor

• Dolžina vektorja

• dimV = size(v)

• velV = dimV(2)

• Ali gre v enem koraku:

• size(v)(2)

• MATLAB "protestira"

• max(size(v))

• sum(x)

• če je x vektor (ali vektor stolpec) : vsota elementov

• Če je x matrika: dobimo vektor vsot stolpcev

• prod(x)

• dot(x, y) : x . y – skalarni produkt