Académique Documents
Professionnel Documents
Culture Documents
GRFICAS EN MATLAB
1. GRFICOS EN EL PLANO
2. GRAFICOS DE MULTIPLES
CURVAS
3. GRFICOS EN MLTIPLES EJES
4. GRAFICOS ESPECIALES EN EL
PLANO
5. GRFICOS DE SUPERFICIES
6. GRFICOS ESPECIALES DE
SUPERFICIES
7. PREPARACIN DE MOVIES O
PELCULAS
GRFICAS EN MATLAB
GRFICOS EN
EL PLANO:
ES
SENCILLO CREAR OBJETOS GRFICOS
MEDIANTE
EXPRESIONES
MATEMTICAS
UTILIZANDO
COMANDOS FUNCIONES CARACTERES
COLORES Y FORMAS
GRFICAS EN MATLAB
FUNCIONES
plot(x,y)
bar(x,y)
barh(x,y)
stairs(x,y
)
polar(x,y
)
pie(x,y)
rose(x,y)
CARACTERES
+
*
o
x
R
Y
G
B
W
M
C
K
COLOR
ROJO
AMARILLO
VERDE
AZUL
BLANCO
MAGENTA
TURQUESA
NEGRO
LNEAS
-:
-.
GRFICAS EN MATLAB
SI X= -1:0.2:1
FUNCIN SIN(X al cubo -X)
plot(x,y,w o);
GRFICAS EN MATLAB
GRFICAS DE MLTIPLES
CURVAS EN MATLAB
MATLAB PROVEE DE LA OPCION PLOT PARA REALIZAR GRFICAS SIMULTANEAS ES
DECIR MS DE UNA CURVA Y ESTABLECE DOS COLORES DISTINTOS.
GRFICAS DE MLTIPLES
CURVAS EN MATLAB
Otra forma es graficar una matriz con columnas
mltiples.
Cada columna se graficar contra un vector x.
x= 0:0.1:5;
w= x;
z= w.^2 -0.9*x +7;
f(1,:)= x.^2 -3*x + 2;
f(2,:)= 2*x.^2 + x -3;
subplot(2,1,1)
plot(x,f(1,:),w,z),title('Grfica con dos curvas:
plot(x,f(1,:),w,z)')
subplot(2,1,2)
plot(x,f), title('Grafica de mltiples funciones:
plot(x,f)')
GRFICAS DE MLTIPLES
CURVAS EN MATLAB
Subplot(m,n,k)
m y n = Dividen la grfica en sub-ventanas
k = Indica la ventana en donde se dibujar
el grfico o la secuencia de las grficas.
t= 0:0,3:5;
x= t elevado al cuadrado;
y= 2*t-5;
z=sin(t);
u=cos(t);
v=abs(t);
w=sqrt(t);
subplot(3,2,1), plot(t,x), title(grfico # 1);
subplot(3,2,2), plot(t,y), title(grfico # 2);
subplot(3,2,3), plot(t,z), title(grfico # 3);
subplot(3,2,4), plot(t,u), title(grfico # 4);
GRFICAS EN MATLAB
GRFICAS ESPECIALES EN
MATLAB
COMANDO
DESCRIPCIN
compass(x,y)
Dibuja flechas de
origen en 0,0
feather(x,y)
fplot(f, [a,b])
Grafica f en el
intervalo a y b
fill(x,y,c)
GRFICA
GRFICAS de SUPERFICIES
COMANDO
DESCRIPCIN
plot3(x,y,z)
Dibuja un conjunto de
puntos en tres
dimensiones
fill3(x,y,z,c)
mesh(x,y,z)
meshc(x,y,z)
Proyecta curvas en el
plano x y
surf(x,y,z)
Grafica superficies en en x
y z
countour3(x,y,z)
GRFICA
GRFICAS ESPECIALES de
SUPERFICIES
Comando
Descripcin
bar3(x,y)
Grficas de barras
verticales
comet3(x,y,z)
Grfica curvas
paramtricas
cylinder(f)
Grfica superficies
de rotacin
sphere
Grfica esferas
unitarias
stem3(x,y,z)
Grfica de puntas
de curva
paramtrica
GRFICA
GRFICAS EN MATLAB
Prctica de grficas en el
1. GRAFICAR SENO DE X AL CUADRADO SIENDO X = DE -1 A 5 CON INTERVALOS
DE 0.1
2. USE LAS BARRAS VERTCALES PARA GRAFICAR LA EXPRESION X AL CUADRADO
SIENDO X= DE -3 A 3 CON UN INTERVALO DE 0,2
3. USE LAS BARRAS HORIZONTALES PARA GRAFICAR COS DE X AL CUBO -2X+1
SIENDO X= DE -3 A 3 CON UN INTERVALO DE 0,2
4. UTILICE STAIRS PARA GRAFICAR EL SENO DE X INICIANDO EN 0 A 10 CON
INTERVALOS DE 0,2
5. REALICE UN GRFICO POLAR DE LA SIGUIENTE EXPRESIN
y=abs(sin(2*t).*cos(2*t)) SIENDO T=DE 0 A 2*PI CON INTERVALOS DE 0,1
6. IMPRIMA UNA GRFICA EN PASTEL CON LOS VALORES QUE DESEE PARA X
7. IMPRIMA LOS VALORES DE X=MATRIZ CUAQUIERA PARA GRAFICAS TIPO ROSE
8. GRAFIQUE LAS SIGUIENTES EXPRESIONES Y UTILICE LOS CARACTERES
PERMITIDOS EN MATLAB
9. X=-3:0,2:3 PARA Y=X AL CUADRADO +3X+8
10.X=-2:0,2:2 PARA Y=ABS(COS(X))
11.X=-3:0,2:4 PARA Y = SIN X AL CUADRADO X
12.X=-3:0,2:3 PARA Y = -X AL CUADRADO +3*ABS(X)+8
plano
PROGRAMACIN
PROGRAMACIN EN MATLAB
MATLAB
ES
UN
LENGUAJE
DE
PROGRAMACIN
QUE
DISPONE
DE
SENTENCIAS PARA REALIZAR PROGRAMAS
E
INTERFACES
UTILIZANDO
BIFURCACIONES Y BUCLES.
ARCHIVOS DE MATLAB
.M
FUNCIONES
(PERMITEN DEFINIR FUNCIONES ANLOGAS A LAS DE
MATLAB CON NOMBRE ARGUMENTOS Y VALORES DE
RETORNO )
ARCHIVOS DE MATLAB
PROGRAMACIN EN MATLAB
ESTRUCTURAS DE
PROGRAMACIN
ASIGNACIN
IF
SWITCH
WHILE
DO WHILE
FOR
Operadores.
ALGUNOS COMANDOS
%
disp
fprintf
rem
break
input
dir
ls
pwd
cd
edit
ESTRUCTURAS CONDICIONALES
(if)
ESTRUCTURAS CONDICIONALES
% Clculo del mximo comn divisor
de dos nmeros naturales
(if)
functionm=max(a,b)
ifa<b
c=b;
b=a;
a=c;
end
whileb>0
c=rem(a,b);
a=b;
b=c;
end
m=a;11.
ESTRUCTURAS CONDICIONALES
(Switch)
ESTRUCTURAS CONDICIONALES
(Switch)
ESTRUCTURAS DE REPETICIN
(While)
ESTRUCTURAS DE REPETICIN
(While)
ESTRUCTURAS DE REPETICIN
(While)
ESTRUCTURAS DE REPETICIN
(for)
ESTRUCTURAS DE REPETICIN
(for)
ESTRUCTURAS DE REPETICIN
(for)
Calcular la suma de los n primeros trminos
de la sucesin 1, 2x, 3x^2, 4x^3, ...
n=input('Cuntos trminos quiere sumar?
');
x=input(Ingrese el valor del numero x ');
suma=1;
fori=2:n
suma=suma+i*x^(i-1);
end
disp('El valor es')
disp(suma)
ESTRUCTURAS DE REPETICIN
(for)
COMBINACIN DE
ESTRUCTURAS
Fnciones
internas
Cos(x)
Sin(x)las
Toma
Toma las
entradas del
usuario
en este caso x
y calcula el
resultado estos
comandos
pueden ser
corridos desde
la consola.
Argumento de entrada
Function resultado=calcular(a)
Argumento de salida
Nombre de la funcin
poly(4)
poly(3)
poly(100)
EJEMPLOS
EVALUAR LA FUNCION = F(X)2XELEVADO AL CUBO+8
X ES UN ESCALAR
function[y]=cubica(x)
y=2*x ^ 3+8
Guardamos con el nombre de la funcin
y corremos en la ventana de comandos
>> cubica(3) y es igual a 62
EJEMPLOS
EJEMPLOS
function[m,s]=media(x)
n=length(x);
m=sum(x)/n;
s=sqrt((sum(x.^2/n)-m^2))
Guardamos con el nombre de la funcin
y corremos en la ventana de comandos
Definimos un arreglo
>>x= [1 2 3 4 5 6];
Llamamos a la funcin
media(x)
Nos devuelve como resultado
>> m= 3,5 y s=1,7078
FUNCIN QUE DEVUELVE MULTIPLES VARABLES
EJEMPLOS
Function numero(x)
If x<0
Opcion=1;
Else opcion=2;
End
Switch opcion
Case 1
disp(x es un nmero positivo);
Case 2
disp(x es un nmero negativo );
Otherwise
disp(x es nulo);
end
Guardamos con el nombre de la funcin
y corremos en la ventana de comandos
Definimos un arreglo
>>x= [1 2 3 4 5 6];
Llamamos a la funcin
media(x)
Nos devuelve como resultado
>> m= 3,5 y s=1,7078
EJERCICIOS A REALIZAR
ell
e
ee
u
u
q
q
n
n
a
tto
accii
o
n
i
n
n
i
g
n
e
i
g
a
e
i
a
m
m
lla
a iim cco
occiim
n
e
no
t
e
o
t
n
n
a
IN
N
o
orrtta
S
p
STTEEI
N
p
I
m
N
E
i
I
m
.
E
i
A
A.
ss
m
m
s
s
E
E
EJERCICIOS A REALIZAR