introd in matlab c1
DESCRIPTION
Curs Introducere in MathlabTRANSCRIPT
![Page 1: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/1.jpg)
Programarea si utilizarea calculatoarelor II
(1) Elemente de baza ale limbajului MATLAB
![Page 2: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/2.jpg)
Ce este MATLAB?
Un sistem interactiv pentru calcule numerice
Are implementati algoritmi care asigura obtinerea unor rezultate certe
Permite efectuarea unor operatii complexe folosind doar una, doua comenzi
Permite definirea unor functii utilizator
Are implementate functii grafice care permit reprezentari de complexitate ridicata
![Page 3: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/3.jpg)
Interfata Matlab
![Page 4: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/4.jpg)
MATLAB ca si calculator
Ordinea de efectuare a operatiilor
Operanzi: +, -, *, /, ^
• Termenii din paranteze
• Ridicarea la putere
• *,/ - de la stanga la dreapta
• +, - de la stanga la dreapta
Toate calculele se efectueaza in dubla precizie, care inseamna aproximativ 15 cifre semnificative dupa virgula
![Page 5: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/5.jpg)
Numere si formatari
Notatia “e” se foloseste de obicei pentru numere foarte mari sau mici si inlocuieste ridicarea numarului la puterea 10
Ex:
-1.3412e+03 = -1.3412x103 = -1341.2
-1.3412e-01 = -1.3412 x10-1 = 0.13412
![Page 6: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/6.jpg)
Numere si formatari
![Page 7: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/7.jpg)
Variabile
Ans – variabila generica
![Page 8: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/8.jpg)
Variabile
Notarea variabilelor se poate face utilizand orice combinatie de litere si cifre, cu conditia ca primul caracter sa fie litera:
NetCost, 4ever, Left2Play, z23es234x3
Exista varibile predefinite care nu ar trebui modificate:
Eps, pi etc
![Page 9: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/9.jpg)
Variabile
![Page 10: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/10.jpg)
Operatii cu numere complexe
![Page 11: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/11.jpg)
Suprimarea afisarii rezultatelor
Daca o operatie este urmata de “;” atunci rezultatul acesteia nu se va afisa
![Page 12: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/12.jpg)
Functia de helpHelp + “cuvant cheie” sau doc + “cuvant cheie”
![Page 13: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/13.jpg)
Functii integrate in meniul MATLAB (built-in)
Functii trigonometricesin, cos, tan cu argumentul in radiani
![Page 14: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/14.jpg)
Alte functii elementare
exp(x)=ex
![Page 15: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/15.jpg)
Vectori – vectorii linie
![Page 16: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/16.jpg)
Operatii cu elementele unui vector
![Page 17: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/17.jpg)
Crearea unui vector cu elemente consecutive cu un pas oarecare
![Page 18: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/18.jpg)
Vectori – Vectorii coloana
Liniile unui vector sunt separate de caracterul “;”
![Page 19: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/19.jpg)
Transpunerea unui vector
Transpunerea unui vector se face cu caracterul ‘
![Page 20: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/20.jpg)
Plotarea functiilor elementare
Sa se ploteze graficul functiei y = sin(3πx) pentru x (0,1)
![Page 21: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/21.jpg)
Plotarea functiilor elementare
![Page 22: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/22.jpg)
Plotarea functiilor elementare
Notatii pe grafice
![Page 23: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/23.jpg)
Plotarea functiilor elementare
![Page 24: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/24.jpg)
Plotarea functiilor elementare
La fiecare comanda plot, fereastra grafica este initializata si se incepe un nou grafic. Daca se doreste reprezentarea mai multor elemente pe acelasi grafic, din comenzi diferite, dupa realizarea primului grafic, se foloseste functia:
Hold
Iar pentru anularea efectului acesteia:
Hold off
![Page 25: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/25.jpg)
Plotare - subploturi
![Page 26: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/26.jpg)
Plotare - subploturi
![Page 27: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/27.jpg)
Operatii cu vectori
Produs scalar
*
![Page 28: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/28.jpg)
Operatii cu vectori
Produs element cu element
“dot product”
.*
![Page 29: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/29.jpg)
Operatii cu vectori
Calculati valoarea functiei y = x sinπx pentru
x = 0,0.25, …, 1
Manual Matlab
![Page 30: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/30.jpg)
Operatii cu vectori
Impartirea element cu element
“dot division”
./
![Page 31: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/31.jpg)
Operatii cu vectori
Estimati valoarea limitei:x
xsinlim
0x
![Page 32: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/32.jpg)
Operatii cu vectori
Ridicarea la putere element cu element
“dot power”
.^
![Page 33: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/33.jpg)
Matrice
Introducerea unei matrice 2x3
731
975A
![Page 34: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/34.jpg)
Matrice - dimensiuni
Size(a,b)
![Page 35: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/35.jpg)
Matrice – configuratii speciale
ones(m,n)
zeros(m,n)
eye(n)
![Page 36: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/36.jpg)
Matricea diagonala
Diag(vector)
![Page 37: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/37.jpg)
Matricea diagonala
Diag(vector)
![Page 38: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/38.jpg)
Operatii cu matrice
Suma si produsul a doua matrice
![Page 39: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/39.jpg)
Produs intre o matrice si un vector
![Page 40: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/40.jpg)
Produsul a doua matrice
Fie A[m][n] şi B[n][l] . Matricea produs dintre A şi B va fi de forma P[m][l]. Formula de calcul este:
1
0]][[]][[]][[
n
kjkkiji BAP
![Page 41: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/41.jpg)
Produs intre doua matrice
![Page 42: Introd in Matlab C1](https://reader033.vdocumente.com/reader033/viewer/2022061604/55cf8ffa550346703ba1eb2c/html5/thumbnails/42.jpg)
Matrice – produsul a doua matrice element cu element (dot product)