Академический Документы
Профессиональный Документы
Культура Документы
Práctica 5: MATLAB
1. Graficar:
𝐵 2𝑥 2 𝑧 2
𝑦=± [1 − ( ) ] [1 − ( ) ]
2 𝐿 𝑇
𝑥 = 𝑙𝑎𝑟𝑔𝑜 −2<x<2
𝑦 = 𝑎𝑛𝑐ℎ𝑜
𝑐𝑜𝑛𝑠𝑡𝑎𝑛𝑡𝑒𝑠:
meshgrid
surf
B=1.2;
L=4;
T=0.5;
[x,z]= meshgrid(-2:0.1:2,-0.5:0.01:0);
y = (B/2)*(1-((2*x)/L).^2).*(1-((z)/T).^2);
surf(x,y,z)
view(3)
xlabel('x (largo)')
ylabel('y (ancho)')
zlabel('z (alto)')
title('y = ±( B/2 )(1- ( 2x / L )^2)(1- ( z / T )^2)')
grid on
hold on
y = -(B/2)*(1-((2*x)/L).^2).*(1-((z)/T).^2);
surf(x,y,z)
view(3)
colormap cool
2. Graficar la función:
𝑓(𝑥, 𝑦, 𝑧) = 𝑥 2 + 2𝑦 2 − 𝑧
Agregar vector gradiente en p(1,1,3) ( graficar su magnitud y dirección). También graficar el plano
tangente con respecto al mismo punto.
meshgrid
meshc
Gráfica de contorno baja el gráfico de malla.
quiver3
Gráfica de velocidad
surf
Puesto que la función corresponde a un paraboloide elíptico, se puede hallar la gráfica por medio de sus
ecuaciones paramétricas o despejando el valor de z al igualar la función a 0. Se realizó un código para cada
caso corroborando la veracidad de los métodos posibles.
𝒇(𝒙, 𝒚, 𝒛) = 𝟎
𝑥 2 + 2𝑦 2 − 𝑧 = 0
𝑧 = 𝑥 2 + 2𝑦 2 (1)
Figura 2. Gráfica de la ecuación 1.
Código de la Figura 2:
surf(x,y,z)
title('PARABOLOIDE ELIPTICO')
xlabel('x')
ylabel('y')
zlabel('z')
view(3)
colormap hsv
zlim([0 5]);
grid on;
𝑥 2 𝑦2
𝑧= +
𝑎2 𝑏2
𝑥 = 𝑎√𝑢 cos(v)
y = b√𝑢 sin(v)
𝑧=𝑢
a=1
1 1
2= → 𝑏= √
𝑏2 2
Código de la Figura 4:
syms u v
a=1
b=sqrt(1/2)
x =a*(sqrt(u))*cos(v)
y =b*(sqrt(u))*sin(v)
z =u
f = x^2 + 2*y^2 - z
ezsurf(x, y, z)
zlim([0 5]);
ylim([-2 2]);
xlim([-4 4]);
view(3)
colormap hsv
title('PARABOLOIDE ELIPTICO')
hold on
grid on;
Plano tangente
𝑝(1,1,3) = 𝑝(𝑥𝑜 , 𝑦𝑜 , 𝑧𝑜 )
𝑓(𝑥, 𝑦, 𝑧) = 𝑥 2 + 2𝑦 2 − 𝑧
𝜕𝑓 𝜕𝑓 𝜕𝑓
|𝑥=𝑥𝑜 (𝑥 − 𝑥𝑜 ) + |𝑥=𝑥𝑜 (𝑦 − 𝑦𝑜 ) + |𝑥=𝑥𝑜 (𝑧 − 𝑧𝑜 ) = 0
𝜕𝑥 𝑦=𝑦𝑜 𝜕𝑦 𝑦=𝑦𝑜 𝜕𝑧 𝑦=𝑦𝑜
𝑧=𝑧𝑜 𝑧=𝑧𝑜 𝑧=𝑧𝑜
2𝑥|𝑥=𝑥𝑜 (𝑥 − 𝑥𝑜 ) + 4𝑦 |𝑥=𝑥𝑜 (𝑦 − 𝑦𝑜 ) + 1 |𝑥=𝑥𝑜 (𝑧 − 𝑧𝑜 ) = 0
𝑦=𝑦𝑜 𝑦=𝑦𝑜 𝑦=𝑦𝑜
𝑧=𝑧𝑜 𝑧=𝑧𝑜 𝑧=𝑧𝑜
2𝑥 + 4𝑦 − 𝑧 = 3
Vector gradiente
𝜕𝑓 ̂ 𝜕𝑓 ̂ 𝜕𝑓 ̂
∇𝑓(𝑥, 𝑦, 𝑧) = 𝑖+ 𝑗+ 𝑘
𝜕𝑥 𝜕𝑦 𝜕𝑧
̂
∇𝑓(𝑥, 𝑦, 𝑧) = 2𝑥 𝑖̂ + 4𝑦𝑗̂ − 𝑘
̂
∇𝑓(1,1,3) = 2 𝑖̂ + 4𝑗̂ − 𝑘
2 ̂ 4 ̂ 1 ̂
𝑑𝑖𝑟𝑒𝑐𝑐𝑖ó𝑛: 𝑢
⃗ = 𝑖+ 𝑗− 𝑘
√21 √21 √21
Figura 7. Vista lateral gráfica definitiva, se puede observar el vector gradiente (flecha azul). Efectivamente
El vector grandiente es perpendicular al plano tangente.
𝜏 = 𝑅𝐶
𝑡
𝑣𝑜𝑙𝑡𝑎𝑗𝑒 𝑐𝑎𝑝𝑎𝑐𝑖𝑡𝑜𝑟 ∶ 𝑉𝑐 (𝑡) = 𝑉𝑠 (1 − 𝑒 −𝜏 )
𝑑𝑉𝑐 (𝑡)
𝑐𝑜𝑟𝑟𝑖𝑒𝑛𝑡𝑒 𝑐𝑎𝑝𝑎𝑐𝑖𝑡𝑜𝑟: 𝑖𝑐 (𝑡) = 𝐶
𝑑𝑡
R = 10000 %ohms
C = 1e-6 %Faradios
Vs = 0
tao = R*C
figure(1)
%Varia corriente
t = 0:0.00001:0.09;
Vs1 = Vs+50;
c1 = Vs*(t+(1/tao)*exp(-t/tao));
a=plot(t,c1)
hold on
t = 0:0.00001:0.09;
Vs = 100;
ic2 = Vs*(t+(1/tao)*exp(-t/tao));
b=plot(t,ic2)
hold on
t = 0:0.00001:0.09;
Vs = 150;
ic3 = Vs*(t+(1/tao)*exp(-t/tao));
c = plot(t,ic3)
hold on
t = 0:0.00001:0.09;
Vs= 200;
ic4 = Vs*(t+(1/tao)*exp(-t/tao));
d = plot(t,ic4)
hold on
t = 0:0.00001:0.09;
Vs= 250;
ic5 = Vs*(t+(1/tao)*exp(-t/tao)); %corriente Capacitor
e = plot(t,ic5)
title('corriente capacitor')
xlabel('t')
M1='50 V';
M2='100 V';
M3='150 V';
M4='200 V';
M5='250 V';
legend([a;b;c;d;e], M1, M2, M3, M4, M5)
%%%%%%%%%%%% voltaje
figure(2)
t = 0:0.00001:0.09;
Vs = 50;
Vc = Vs*(1-exp(-t/tao));
v1=plot(t,Vc)
hold on
t = 0:0.00001:0.09;
Vs = 100;
Vc = Vs*(1-exp(-t/tao));
v2=plot(t,Vc)
hold on
t = 0:0.00001:0.09;
Vs = 150;
Vc = Vs*(1-exp(-t/tao));
v3=plot(t,Vc)
hold on
t = 0:0.00001:0.09;
Vs = 200;
Vc = Vs*(1-exp(-t/tao));
v4=plot(t,Vc)
hold on
t = 0:0.000001:0.09;
Vs = 250;
Vc = Vs*(1-exp(-t/tao)); %Voltaje Capacitor
v5=plot(t,Vc)
title('Voltaje capacitor')
xlabel('t[s]')
legend([v1;v2;v3;v4;v5], M1, M2, M3, M4, M5)
4. Escribir un script de MATLAB que reconozca los caracteres de una placa de vehículo colombiana.
Tome una foto de una placa y escribir el script en base al ejemplo del toolbox de visión por
computador “Recognize Text Using Optical Character Recognition (OCR)”
imread
imshow
A patir de las siguientes dos líneas de código se obtiene un objeto ocrText que contiene información del
reconocimiento óptico de caracteres en la imagen, dando la ubicación del texto reconocido. En este caso la
información es de la imagen de la Figura 13.
placa = imread('placad.jpg');
carplaca = ocr(placa)
carplaca =