1 / 19

Práctica 1

Práctica 1. Introducción a MATLAB. Introducción a MATLAB. Mandatos básicos Variables Funciones Complejos Vectores Matrices Polinomios Gráficas Programación. Mandatos básicos. help, help tema dir diary fichero Comentarios: % Edición de líneas de comando Cortar y Pegar.

peers
Télécharger la présentation

Práctica 1

An Image/Link below is provided (as is) to download presentation 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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Práctica 1 Introducción a MATLAB

  2. Introducción a MATLAB • Mandatos básicos • Variables • Funciones • Complejos • Vectores • Matrices • Polinomios • Gráficas • Programación

  3. Mandatos básicos • help, help tema • dir • diary fichero • Comentarios: % • Edición de líneas de comando • Cortar y Pegar

  4. Asignar a = 3, b = 4 Listar ans who whos Eliminar clear b Guardar save fichero Recuperar load fichero Variables

  5. Número p: pi Unidad imaginaria: i,j Precisión: eps Infinito: Inf Indeterminación: NaN Cadenas de caracteres 'Esto es una cadena' Esto no Formatos numéricos format long format short format rat Constantes y cadenas

  6. help elfun sin cos tan exp ezplot(x3+1)/x asin acos atan log Funciones (x3+1)/x 8 6 4 2 0 -2 -4 -6 -2 0 2 x

  7. Módulo y argumento abs(z) angle(z) Representación gráfica plot(z,'*') compass(z) Forma binómica z = 3 + 4i Parte real e imaginaria real(z) imag(z) Complejo conjugado conj(z) Números Complejos

  8. Edición u = [1 2 3] v = [1,2,3] w = [1;2;3] w = [123] Progresivos 0:0.1:10 linspace(0,1,11) Normas norm(v,2) norm(v,1) norm(v,inf) 1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 -0.6 -0.8 -1 -1 -0.6 -0.2 0.2 0.6 1 Vectores

  9. Suma: u+v de comps.: sum(u) Productos por escalar:2*u escalar:dot(u,v) elemental:u.*v matricial:u*w, w*u de comps.:prod(u) Transpuesta: u' Voltear fliplr(x) flipud(x') Funciones x = -1:0.01:1 y = tanh(x) plot(x,y) Operaciones con vectores

  10. Edición A = [1,2;3,4] B = [-1 -2-3 -4] Elemento: A(2,1) Fila: A(2,:) Columna: A(:,1) Bloques M = [A,B;B,A] Submatrices M41 = M(1:3,2:4) fil = [1,2,4] col = [1,3,4] M32 = M(fil,col) Matrices

  11. Suma y resta:+ - Producto:* .* Potencia:^ .^ Cociente izq.:/ ./ Cociente der.:\ .\ Transpuesta:' .' Determinante det(A) Inversa inv(A) Rango rank(A) Operaciones con matrices

  12. Identidad de orden n: eye(n) Nula de tamaño m×n: zeros(m,n) Matriz de unos: ones(m,n) Matriz aleatoria: rand(m,n) Matriz de Hilbert: hilb(n) Matriz de van der Monde: vander(x) Matrices usuales

  13. Polinomios • Coeficientes p=[2/3 -5 34/3 -7] • Valor de p en x: polyval(p,x) • Raíces: roots(p) • Multiplicación: conv(p,q) • División con resto: [q,r] = deconv(p,d)

  14. 8 6 4 2 0 -2 -4 -6 -8 0 1 2 3 4 5 Formato gráfico • Estilo de línea • Trazo: ·, o, x, +, –, *, :, – ·, – – • Color: r, g, b, y, m, c, w, k • Títulos • title, • xlabel, ylabel • text, gtext Máximo Mínimo

  15. 90 1 120 60 0.75 0.5 150 30 0.25 180 0 210 330 300 240 270 Curvas planas • Cartesianas • ezplot • fplot • plot • Polares • polar • Paramétricas • plot

  16. Funciones de dos variables • Crear la malla de puntos en el plano XY» x = -1:0.1:1; y = x;» [X,Y] = meshgrid(x,y); • Evaluar la función sobre X, Y» z = X .* Y; • Representar z respecto a X e Y» surf(x,y,z)

  17. Opciones gráficas 3D • Malla transparente» mesh(x,y,z), hidden off • Superficie color degradado sin malla» surf(x,y,z), shading interp • Mapa físico» pcolor(x,y,z), hold on» contour(x,y,z,'k') % k es negro

  18. Curvas en 3D y superficies • Curvas en 3D» t = 0:pi/500:4*pi;» x = sin(t); y = cos(t); z = t;» plot3(x,y,z) % Hélice • Superficies de revolución» cylinder(x); • Esfera» sphere

  19. FIN

More Related