<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5635612627780359488</id><updated>2024-11-05T19:01:39.767-08:00</updated><category term="Videos"/><category term="Codigos"/><category term="Curso 2012"/><category term="Temas básicos"/><category term="Códigos"/><category term="Actividades"/><category term="gráficas"/><category term="Procesamiento de imágenes"/><category term="Temas avanzados"/><category term="Información"/><category term="material extra"/><category term="Filtros"/><category term="Práctica"/><category term="Respuestas"/><category term="estadística"/><category term="Procesamiento de señales"/><category term="juegos"/><title type='text'>5 Minutos de Matlab</title><subtitle type='html'>Curso autodidacta/complementario de Matlab: videos, ejercicios, códigos y más ...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default?start-index=26&amp;max-results=25'/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>67</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-672449095768030143</id><published>2014-10-10T16:29:00.001-07:00</published><updated>2014-10-10T16:29:11.711-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Procesamiento de imágenes"/><title type='text'>Cómo obtener el perfil de intensidad de una imagen con matlab</title><content type='html'>&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;//www.youtube.com/embed/TYfKzxBsSeM?rel=0&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Resumen&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
En esta ocasiones requerimos obtener el perfil de intensidad de una imagen. Es decir, cual es el valor entre 0 y 255 que adquiere una serie de pixeles marcados en una línea arbitraria dentro de una imagen, incluso cuando se presenta varios canales. Para ello usamos el versátil comando &lt;a href=&quot;http://www.mathworks.com/help/images/ref/improfile.html&quot;&gt;improfile&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Preguntas para pensar&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
2) Además de analizar patrones de difracción e interferogramas ópticas. ¿En que otras situaciones es útil obtener el perfil de intensidad de una imagen?&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Ejercicio&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1)&lt;/b&gt; El comando improfile permite marcar multiples líneas en una misma imagen. Obtnen gráficas diferenciadas de esta múltiples lineas&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/672449095768030143/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2014/10/como-obtener-el-perfil-de-intensidad-de.html#comment-form' title='1 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/672449095768030143'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/672449095768030143'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2014/10/como-obtener-el-perfil-de-intensidad-de.html' title='Cómo obtener el perfil de intensidad de una imagen con matlab'/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-1343106713952259677</id><published>2014-08-17T13:54:00.001-07:00</published><updated>2014-08-17T13:54:34.887-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Códigos"/><category scheme="http://www.blogger.com/atom/ns#" term="Procesamiento de imágenes"/><category scheme="http://www.blogger.com/atom/ns#" term="Temas avanzados"/><title type='text'>Cómo poner textura de imagen a una superficie 3D en Matlab </title><content type='html'>&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;//www.youtube.com/embed/z7fQoLoNlfs?rel=0&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Resumen&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiM5-A3PDmyz9faVtCarON65bQhhNi8GClO5hb7qTZCVx8gGPzjHsJkBFM53Y0KDQNLIOPga2p86V865ZuEuRCdO8xXZPiBduxRbCBkWR4P1nKUP7pelbNu1tbSMoOBVgklD2anTeyahIg/s1600/blackhole.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiM5-A3PDmyz9faVtCarON65bQhhNi8GClO5hb7qTZCVx8gGPzjHsJkBFM53Y0KDQNLIOPga2p86V865ZuEuRCdO8xXZPiBduxRbCBkWR4P1nKUP7pelbNu1tbSMoOBVgklD2anTeyahIg/s1600/blackhole.jpg&quot; height=&quot;150&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Muchos video juego y simuladores usan texturas de imágenes sobre superficies de polinomios. Como si coloran una piel a un armazón. Aquí exploramos cómo se hace esta superposición en Matlab. &lt;br /&gt;
&lt;br /&gt;
Además mostramos que se pueden cargar imagenes desde Internet a nuestro programa de Matlab.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Preguntas para pensar&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;1) &lt;/b&gt;¿Cómo puede ser importante este programa para una aplicación médica?&lt;br /&gt;
&lt;b&gt;2) &lt;/b&gt;¿Cómo se eliminan las lineas guías (cuadricula) de la imagen 3D?&lt;br /&gt;
4) Las proyecciones planas se incorporaron a la superficie 3D. Lo que crea sitios con discontinuidades. ¿Como se puede mejorar el ajuste de una imagen que funciona como piel sobre una superficie digital?&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Código Matlab&lt;/b&gt;&lt;br /&gt;
% Superficie 3D con una textura de imagen&lt;br /&gt;
&lt;br /&gt;
% Inicialización&lt;br /&gt;
clear all; close all; clc; format compact;&lt;br /&gt;
&lt;br /&gt;
% Constantes y valores iniciales&lt;br /&gt;
k = -.5; j = 0.6;&lt;br /&gt;
&lt;br /&gt;
% Generando los valores x,y,z&lt;br /&gt;
[x,y] = meshgrid(-3:.2:3, -3:.2:3);&lt;br /&gt;
z = k.*(1-(cos(x.^2+y.^2))./(x.^2+y.^2+j));&lt;br /&gt;
&lt;br /&gt;
% Dibujando la superficie&lt;br /&gt;
h = surf(x,y,z);&lt;br /&gt;
&lt;br /&gt;
% Añadiendo una imagen a la superficie&lt;br /&gt;
img = imread(&#39;http://upload.wikimedia.org/wikipedia/en/5/5d/Ubinas_ali_2010205.jpg&#39;);&lt;br /&gt;
&lt;br /&gt;
% Ubinas: el volcan más reciente de Perú&lt;br /&gt;
set(h,&#39;CData&#39;,img,&#39;FaceColor&#39;,&#39;texturemap&#39;)&lt;br /&gt;
axis off&lt;br /&gt;
% fin del guión.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/1343106713952259677/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2014/08/como-poner-textura-de-imagen-una.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/1343106713952259677'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/1343106713952259677'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2014/08/como-poner-textura-de-imagen-una.html' title='Cómo poner textura de imagen a una superficie 3D en Matlab '/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiM5-A3PDmyz9faVtCarON65bQhhNi8GClO5hb7qTZCVx8gGPzjHsJkBFM53Y0KDQNLIOPga2p86V865ZuEuRCdO8xXZPiBduxRbCBkWR4P1nKUP7pelbNu1tbSMoOBVgklD2anTeyahIg/s72-c/blackhole.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-8704984054733114063</id><published>2013-09-30T19:44:00.000-07:00</published><updated>2013-09-30T19:44:38.699-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Códigos"/><category scheme="http://www.blogger.com/atom/ns#" term="gráficas"/><category scheme="http://www.blogger.com/atom/ns#" term="Temas avanzados"/><title type='text'>Cómo hacer el símbolo del  pentagrama con Matlab</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;//www.youtube.com/embed/y2xUFThP61c?rel=0&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhxfrr-k0uG8SIb0b12v0tSgQpreGTbV24FR2V0n6pzBxWX-28Xq3lIJdpiA8tvS4R2QKOyGqNjkZto4El-OeeoaOCPECn1nYWGppZQ_D-MhhOQpG_j5Vhusy82Dv28u_bMqWoKp8QalU/s1600/pentabrama_matlab.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;190&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhxfrr-k0uG8SIb0b12v0tSgQpreGTbV24FR2V0n6pzBxWX-28Xq3lIJdpiA8tvS4R2QKOyGqNjkZto4El-OeeoaOCPECn1nYWGppZQ_D-MhhOQpG_j5Vhusy82Dv28u_bMqWoKp8QalU/s200/pentabrama_matlab.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Resumen&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Un &lt;a href=&quot;http://es.wikipedia.org/wiki/Pentagrama_(geometr%C3%ADa)&quot;&gt;pentagrama&lt;/a&gt; es una estrella de cinco picos, hecha con cinco trazos. Tiene propiedades geométricas muy interesantes.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Para construirla, aquí dibujamos una linea horizontal, y la giramos mediante la función &lt;b&gt;rot2d&lt;/b&gt;, cuyo al código encontraras al final de esta entrada. El guión del pentagrama se basa en dibujar una linea horizontal y luego rotarla. Sin embargo, se tiene cuidado de usar adecuadamente las definiciones de operaciones de matrices para obtener los vectores rotados.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Preguntas para pensar&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1)&lt;/b&gt;&amp;nbsp;¿En que situaciones Matlab es una herramienta cómoda y adecuada para dibujar?, ¿y en situaciones Matlab es una pesima herramienta para hacer dibujos?&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;2)&lt;/b&gt; ¿Mejorando el entorno gráfico de Matlab, hace más amigable sus funciones de dibujo?&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Ejercicios&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1) &lt;/b&gt;Dibuje una &lt;a href=&quot;http://es.wikipedia.org/wiki/Estrella_de_David&quot;&gt;estrella de David&lt;/a&gt;, utilizando de base los códigos de esta entrada&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;2)&lt;/b&gt; Explique con un ejemplo la importancia de de usar &lt;b&gt;x = [x x(1)]; &lt;/b&gt;para obtener una rotación adecuada.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;3)&lt;/b&gt; ¿En que coordenadas el punto en que gira la linea horizontal?, ¿Cómo puede especificar otro punto como pivote de los giros?&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Códigos Matlab&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
function [xt, yt] = rot2d(t, x, y)&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
% La función &amp;nbsp;rot2d rota un objeto bidimensional&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
% que es representado por dos vectores: X y Y&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
% El ángulo de rotación es t, en radianes.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
r = [cos(t) -sin(t); sin(t) cos(t)];&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
x = [x x(1)];&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
y = [y y(1)];&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
z = r*[x;y];&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
xt = z(1,:);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp;yt = z(2,:);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
%guión para dibujar el pentagrama&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div&gt;
%% Pentagrama&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
% &amp;nbsp;Author: Vicente Torres Zuñiga&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
% &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
% Guión Matlab para graficar el símbolo de un pentagrama en el sistema&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
% cartesiano&lt;/div&gt;
&lt;div&gt;
% El símbolo consiste en un círculo con un pentagrama en interior -un&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
% estrella de cinco puntas dibujada con cinco lineas %&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
%&lt;/div&gt;
&lt;div&gt;
% El algoritmo se enfoca en obtener las coordenadas de dibujo:&lt;/div&gt;
&lt;div&gt;
% primero de un circulo, luego de una linea horizontal, que posteriormente&lt;/div&gt;
&lt;div&gt;
% se rota para generar cuatro lineas para completar el pentagrama&lt;/div&gt;
&lt;div&gt;
%&lt;/div&gt;
&lt;div&gt;
close all; clear; clc % limpiamos la casa&lt;/div&gt;
&lt;div&gt;
num_puntos = 250; % número de puntos&lt;/div&gt;
&lt;div&gt;
t = linspace(0, 2*pi, num_puntos); % Intervalo&lt;/div&gt;
&lt;div&gt;
noLados = 5; % Número de lados del polígono&lt;/div&gt;
&lt;div&gt;
AnguloInt = 2*pi/noLados; % Ángulo interior del polígono&lt;/div&gt;
&lt;div&gt;
%&lt;/div&gt;
&lt;div&gt;
% Variables del círculo&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
r = 2; % Radio&lt;/div&gt;
&lt;div&gt;
h = 0; k = 0; % Coordenadas del centro&lt;/div&gt;
&lt;div&gt;
%&lt;/div&gt;
&lt;div&gt;
% Ecuación parámetrica del círculo:&lt;/div&gt;
&lt;div&gt;
x = r*cos(t)+h; y = r*sin(t)+k;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
%&lt;/div&gt;
&lt;div&gt;
%% Ecuaciones para la linea horizontal&lt;/div&gt;
&lt;div&gt;
% Longitud de la linea horizontal&lt;/div&gt;
&lt;div&gt;
lH = 2*r*sin(AnguloInt);&lt;/div&gt;
&lt;div&gt;
% Distancia de la linea horizontal al centro: (0,0)&lt;/div&gt;
&lt;div&gt;
dist_lH = r*cos(AnguloInt);&lt;/div&gt;
&lt;div&gt;
%&lt;/div&gt;
&lt;div&gt;
% Definición del intervalo de la línea horizontal&lt;/div&gt;
&lt;div&gt;
xH = linspace(-lH/2, lH/2, num_puntos);&lt;/div&gt;
&lt;div&gt;
% Definición de vectores&lt;/div&gt;
&lt;div&gt;
L = zeros(2,num_puntos);&lt;/div&gt;
&lt;div&gt;
L(1,:) = xH;&lt;/div&gt;
&lt;div&gt;
L(2,:) = -dist_lH;&lt;/div&gt;
&lt;div&gt;
%&lt;/div&gt;
&lt;div&gt;
[L0rx &amp;nbsp;L0ry] = rot2d(AnguloInt*0, L(1,:), L(2,:));&lt;/div&gt;
&lt;div&gt;
[L1rx &amp;nbsp;L1ry] = rot2d(AnguloInt, L(1,:), L(2,:));&lt;/div&gt;
&lt;div&gt;
[L2rx &amp;nbsp;L2ry] = rot2d(AnguloInt*2, L(1,:), L(2,:));&lt;/div&gt;
&lt;div&gt;
[L3rx &amp;nbsp;L3ry] = rot2d(AnguloInt*3, L(1,:), L(2,:));&lt;/div&gt;
&lt;div&gt;
[L4rx &amp;nbsp;L4ry] = rot2d(AnguloInt*4, L(1,:), L(2,:));&lt;/div&gt;
&lt;div&gt;
%&lt;/div&gt;
&lt;div&gt;
% Gráficas&lt;/div&gt;
&lt;div&gt;
hold on&lt;/div&gt;
&lt;div&gt;
plot(x,y, &#39;r&#39;, &#39;LineWidth&#39;, 4) % círculo&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
plot(L0rx, L0ry, &#39;LineWidth&#39;, 4) &amp;nbsp;% línea horizontal&lt;/div&gt;
&lt;div&gt;
plot(L1rx, L1ry, &#39;LineWidth&#39;, 4)&lt;/div&gt;
&lt;div&gt;
plot(L2rx, L2ry, &#39;LineWidth&#39;, 4)&lt;/div&gt;
&lt;div&gt;
plot(L3rx, L3ry, &#39;LineWidth&#39;, 4)&lt;/div&gt;
&lt;div&gt;
plot(L4rx, L4ry, &#39;LineWidth&#39;, 4)&lt;/div&gt;
&lt;div&gt;
axis square off&lt;/div&gt;
&lt;div&gt;
hold off&lt;/div&gt;
&lt;div&gt;
% fin del guión/script&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/8704984054733114063/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2013/09/como-hacer-el-simbolo-del-pentagrama.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/8704984054733114063'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/8704984054733114063'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2013/09/como-hacer-el-simbolo-del-pentagrama.html' title='Cómo hacer el símbolo del  pentagrama con Matlab'/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhxfrr-k0uG8SIb0b12v0tSgQpreGTbV24FR2V0n6pzBxWX-28Xq3lIJdpiA8tvS4R2QKOyGqNjkZto4El-OeeoaOCPECn1nYWGppZQ_D-MhhOQpG_j5Vhusy82Dv28u_bMqWoKp8QalU/s72-c/pentabrama_matlab.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-7094349011228394769</id><published>2013-09-17T16:37:00.002-07:00</published><updated>2013-09-17T16:37:34.418-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Códigos"/><category scheme="http://www.blogger.com/atom/ns#" term="juegos"/><title type='text'>Descubriendo huevos de Pascua en Matlab</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;//www.youtube.com/embed/ikCSdif4Y0w?rel=0&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Los huevos de Pascua son imagenes, fragmentos de audio o video o pedazos de código con una funcion inesperada e intencional de un programa. Fueron dejadas por los programadores para dejar un testimonio de su trabajo y aficiones; pero tal vez lo princiapal, estan ahí para que las descubramos.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Hay que enfatizar que los huevos de pascua no son demos, ni errores de programación. &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
De mis ejemplos favoritos en Matlab debo mendicionar siguientes: &lt;/div&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;fifteen&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;load handel, sound(y,Fs)&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;load audio48, sound(signal48kHz, Fs48)&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;why&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;spy&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;image&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;¡Debes probarlas!&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;
Unas notas extras: &lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1)&lt;/b&gt; Parece que las versiones modernas de Matlab dejo de aparecer la imagen del espia. Pero la puedes recuperar con el código de una &lt;a href=&quot;http://stackoverflow.com/questions/17378200/matlab-database-searching/17379616#17379616&quot;&gt;entrada de stackoverflow&lt;/a&gt;.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;2)&lt;/b&gt; Image tiene una interesante historia, que la cuenta -&lt;a href=&quot;http://blogs.mathworks.com/steve/2006/10/17/the-story-behind-the-matlab-default-image/&quot;&gt;en su blog&lt;/a&gt;- Steve Eddins. &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Para ver las demas imagenes que se ocultan en la imagen por defecto puedes usar el siguiente código Matlab:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
defImage = pow2(get(0,&#39;DefaultImageCData&#39;),47);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
imgCell = repmat({zeros(size(defImage))},8,7);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
for shift = 0:52&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
imgCell{shift+1} = bitshift(defImage,shift);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
end;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
allImages = cell2mat(imgCell.&#39;);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
imshow(allImages,[min(allImages(:)) max(allImages(:))]);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
%fin del script&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/7094349011228394769/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2013/09/descubriendo-huevos-de-pascua-en-matlab.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/7094349011228394769'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/7094349011228394769'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2013/09/descubriendo-huevos-de-pascua-en-matlab.html' title='Descubriendo huevos de Pascua en Matlab'/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-7384007116906008495</id><published>2013-09-11T09:56:00.001-07:00</published><updated>2014-07-17T11:24:18.794-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Codigos"/><category scheme="http://www.blogger.com/atom/ns#" term="Procesamiento de imágenes"/><category scheme="http://www.blogger.com/atom/ns#" term="Temas avanzados"/><title type='text'>Cómo ocultar una imagen en una rejilla espacial con Matlab</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;//www.youtube.com/embed/t3R5k0tAHm8?rel=0&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
Se han hecho populares estas imágenes en Facebook, son fotos ocultadas a través de una densa rejilla espacial. Te mostramos cómo hacer esta ilusión óptica con Matlab.&lt;br /&gt;
&lt;br /&gt;
Básicamente, se trata de disminuir el contraste de las fotos, alejarse de los tonos oscuros y luego introducir muchas franjas oscuras en la imagen. El resultado es que percibimos primero franjas oscuras y claras, pues entre ellas hay más contraste, cuando cambiamos de perspectiva (al inclinar la pantalla o la cabeza o alejarnos de la imagen) o sacudir la cabeza podemos ver la imagen oculta.&lt;br /&gt;
&lt;br /&gt;
Se trata más de una curiosidad que de un verdadero sistema de criptografía, asi que diviértanse con el código y las imágenes que dejo en esta &amp;nbsp;entrada.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Preguntas para pensar&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;1)&lt;/b&gt; ¿Por qué aparece la imagen cuando cambiamos de perspectiva?&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Ejercicios&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;1)&lt;/b&gt; Altera &amp;nbsp;el código para que sea una función de cuatro parámetros, que de de salida una imagen .gif&lt;br /&gt;
&lt;br /&gt;
Imagen utilizada&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9trJLRJXidw8umTyA3CvrrnU1LwPX7ePSGwKgl_MFreh5b2zYoNGzQTXCax4r8KK_SQ0N2VZ3Qn80gv0ZiPTRZ95RFqWhjgIqU3VD59QacL5wvxfUf53-v5USXKoZfi30uJGgIBOQjHo/s1600/maz.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9trJLRJXidw8umTyA3CvrrnU1LwPX7ePSGwKgl_MFreh5b2zYoNGzQTXCax4r8KK_SQ0N2VZ3Qn80gv0ZiPTRZ95RFqWhjgIqU3VD59QacL5wvxfUf53-v5USXKoZfi30uJGgIBOQjHo/s400/maz.jpg&quot; height=&quot;320&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
Imagen de salida&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT9BHukFLvEA3D_Rs876sCg1LW12KLL-ae9p4PczIoyKPDxZN67tBFpWrfm2AcRktWrZeTZk0A6wLVy6PC_Q6mNi9SHXQdH4WegHiOfCPPooK-q8Fk-4PtWdUrubpDcPGXGtMIzM9W0no/s1600/rejilla_espacial_maz.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT9BHukFLvEA3D_Rs876sCg1LW12KLL-ae9p4PczIoyKPDxZN67tBFpWrfm2AcRktWrZeTZk0A6wLVy6PC_Q6mNi9SHXQdH4WegHiOfCPPooK-q8Fk-4PtWdUrubpDcPGXGtMIzM9W0no/s400/rejilla_espacial_maz.gif&quot; height=&quot;321&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;Guión Matlab&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
% A limpiar la casa&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp;clear all; close all; clc;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
% Cargar la imagen y ponerla en grises&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
im_fuente = rgb2gray(imread(&#39;maz.jpg&#39;));&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
% cambia la clase de una variable&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
imgs = cast(im_fuente,&#39;double&#39;);&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
% La imagen se ajusta a 60 tonos de gris,&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
img = 60*((imgs)./(max(max(imgs))));&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
img = img + 195; % desplazar los tonos a 195&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
% al final tengo tonos de 195 a 255&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
[f c d] = size(img); % el proceso es para cada capa&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
% Paso es el número de columnas negras en la imagen final&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
paso = floor(c/160); %redondea hacia abajo, frecuencia 1/160&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
for i = 1:2*paso:c&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; img(:,i:i+paso,:) = 0; %img suele tener tres capas&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
end&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
im_final = cast(img,&#39;uint8&#39;);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
imshow(im_final); % ver para creer&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
%fin del guión&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
Más información en la &lt;a href=&quot;http://thilinasameera.wordpress.com/2012/04/12/photo-effects-using-matlab-2-0-optical-illusion-using-matlab-shake-your-head-and-see-the-image/&quot;&gt;ref&lt;/a&gt;.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/7384007116906008495/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2013/09/como-ocultar-una-imagen-en-una-rejilla.html#comment-form' title='1 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/7384007116906008495'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/7384007116906008495'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2013/09/como-ocultar-una-imagen-en-una-rejilla.html' title='Cómo ocultar una imagen en una rejilla espacial con Matlab'/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9trJLRJXidw8umTyA3CvrrnU1LwPX7ePSGwKgl_MFreh5b2zYoNGzQTXCax4r8KK_SQ0N2VZ3Qn80gv0ZiPTRZ95RFqWhjgIqU3VD59QacL5wvxfUf53-v5USXKoZfi30uJGgIBOQjHo/s72-c/maz.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-2219375133543716061</id><published>2013-09-09T20:16:00.000-07:00</published><updated>2014-08-13T20:42:18.347-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Codigos"/><category scheme="http://www.blogger.com/atom/ns#" term="estadística"/><title type='text'>Retirar datos atípicos (outliers) de una distribución de datos con Matlab</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;//www.youtube.com/embed/uEYHGY-zzVQ?rel=0&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Los datos atípicos son datos que se alejan mucho de promedio de una distribución. Por lo general, se interpretan como errores experimentales aleatorios, por ello se suelen remover. En esta ocasión te muestro un &lt;i&gt;script&lt;/i&gt; que usa cuartiles estadísticos para remover tales datos.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Preguntas para pensar&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1) &lt;/b&gt;&amp;nbsp;En que caso un dato atípico brinda información experimental relevante y no debe removerse de la serie.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Ejercicios&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1)&lt;/b&gt; Sugiere una modificación al guion presentado para usar la desviación-estándar como base para eliminar los datos atípicos.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;GUIÓN MATLAB&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
%% Primer guión para remover datos atípicos&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
clc; clear; close all&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
%% Información de entrada&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Y = [10 20 -150 40 50 60 70 200 90 100];&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
X = [2 4 6 8 10 12 14 16 18 20];&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
%% Cálculos&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
IQR = iqr(Y); %intervalo &amp;nbsp;intercuartil,&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp; &amp;nbsp; % la diferencia entre el tercer &amp;nbsp;y el primer cuartil&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp; &amp;nbsp; % de una distribución: 75%-25% de Y&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp; &amp;nbsp; % σ= IQR * 0.7413&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
lowr=prctile(Y,25)-1.5*IQR; %Percentiles. Q1 - 1.5IQR.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
highr=prctile(Y,75)+1.5*IQR; % Q3 + 1.5IQR&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
new_Y = Y(Y&amp;gt;lowr &amp;amp; &amp;nbsp; Y&lt;highr p=&quot;&quot;&gt;&lt;highr p=&quot;&quot;&gt;&lt;br /&gt;&lt;/highr&gt;
&lt;highr p=&quot;&quot;&gt;new_X = X&lt;/highr&gt;(Y&amp;gt;lowr &amp;amp; &amp;nbsp; Y&lt;highr p=&quot;&quot;&gt;&lt;/highr&gt;&lt;/highr&gt;&lt;/div&gt;
&lt;highr p=&quot;&quot;&gt;&lt;/highr&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
%%ver; es creer&lt;/div&gt;
&lt;highr p=&quot;&quot;&gt;&lt;/highr&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
hold on&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
plot(X, Y, &#39;bo&#39;,&#39;MarkerSize&#39;,20)&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
plot(new_X, new_Y, &#39;kx&#39;,&#39;MarkerSize&#39;,20)&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
hold off&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
%fin del guión&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/2219375133543716061/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2013/09/retirar-datos-atipicos-outliers-de-una.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/2219375133543716061'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/2219375133543716061'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2013/09/retirar-datos-atipicos-outliers-de-una.html' title='Retirar datos atípicos (outliers) de una distribución de datos con Matlab'/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-248523504209009998</id><published>2013-04-29T15:13:00.001-07:00</published><updated>2013-04-29T15:13:09.658-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Codigos"/><title type='text'>Juego de volados y casinos ricos</title><content type='html'>&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtVYkjHEpGkjt_cLyaghUydfqynaeLxUGN_WhPnL2VTSfxddW29fbFpwwf7DBv5DdNZwWlAh3cfWQ-A6_yNhCALM0WJ_IE3xvdVPWCPZM26yF-Cfj-pSsVJYst4Is7QOhbbuM1YyWbgfk/s1600/casino_volados.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;155&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtVYkjHEpGkjt_cLyaghUydfqynaeLxUGN_WhPnL2VTSfxddW29fbFpwwf7DBv5DdNZwWlAh3cfWQ-A6_yNhCALM0WJ_IE3xvdVPWCPZM26yF-Cfj-pSsVJYst4Is7QOhbbuM1YyWbgfk/s400/casino_volados.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Guión:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
%% ¿En cuanto tiempo un casino te deja sin dinero?&lt;br /&gt;
% este guion simula un juego de tirar una moneda entre un casino y un&lt;br /&gt;
% apostador.&lt;br /&gt;
&lt;br /&gt;
%% Guión escrito por Vicente Torres Zúñiga; 18 de abril 2003.&lt;br /&gt;
&lt;br /&gt;
clc; clear; close all % Limpia la memoria&lt;br /&gt;
&lt;br /&gt;
casino = 100000; % Dinero con el que empieza el casino&lt;br /&gt;
apostador = 10; % Dinero con el que empieza el apostador&lt;br /&gt;
&lt;br /&gt;
casino_zero  = casino;&lt;br /&gt;
apostador_zero = apostador;&lt;br /&gt;
&lt;br /&gt;
num_evento = 0; % Número de veces que han apostado, que se inicia en cero.&lt;br /&gt;
&lt;br /&gt;
dinero_apostador(casino) = 0; % Tentativamente pongo este vector para&lt;br /&gt;
% hacer más rapida la asignición de memoria. Pero al final el vector puede&lt;br /&gt;
% ser más grande o pequeño que esta asignación&lt;br /&gt;
&lt;br /&gt;
% Todas las apuestas son iguales, de una unidad. Es decir, en un juego&lt;br /&gt;
% se pierde o gana una unidad.&lt;br /&gt;
&lt;br /&gt;
while (apostador &amp;gt; 0 &amp;amp;&amp;amp; casino &amp;gt; 0)&lt;br /&gt;
num_evento = num_evento +1;&lt;br /&gt;
dinero_apostador(num_evento) = apostador;&lt;br /&gt;
moneda = rand(1); % rand brinda números pseudoaleatorios entre 0 y 1&lt;br /&gt;
if moneda &amp;gt;=0.5 % gana el casino&lt;br /&gt;
casino = casino +1;&lt;br /&gt;
apostador = apostador -1;&lt;br /&gt;
&lt;br /&gt;
else % gana apostador&lt;br /&gt;
casino = casino - 1;&lt;br /&gt;
apostador = apostador +1;&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
porciento_perdida_casino = 100*max(dinero_apostador)/casino_zero; % porcentualmente cuanto es lo máximo que&lt;br /&gt;
% le puedo sacar al casino&lt;br /&gt;
porciento_ganancia_apostador = 100*(max(dinero_apostador)- apostador_zero)/apostador_zero; % porcentualmente cuanto es lo máximo que&lt;br /&gt;
% le puedo sacar al casino&lt;br /&gt;
num_juegos = num_evento; %cuantos juegos realizamos &lt;br /&gt;
&lt;br /&gt;
% Vizualización &lt;br /&gt;
axes(&#39;fontsize&#39;,14,&#39;fontweight&#39;,&#39;b&#39;)&lt;br /&gt;
plot(dinero_apostador,&#39;b&#39;, &#39;LineWidth&#39;,6)&lt;br /&gt;
&lt;br /&gt;
xlabel(&#39;Número de juego, N&#39;, &#39;fontsize&#39;,20,&#39;fontweight&#39;,&#39;b&#39;)&lt;br /&gt;
ylabel(&#39;Dinero del apostador, D&#39;, &#39;fontsize&#39;,20,&#39;fontweight&#39;,&#39;b&#39;)&lt;br /&gt;
title([&#39;Al principio, el dinero del casino es &#39;, num2str(casino_zero./apostador_zero), &#39; veces más grande que el del apostador&#39;],  &#39;fontsize&#39;,20,&#39;fontweight&#39;,&#39;b&#39;)&lt;br /&gt;
set(gca, &#39;Fontsize&#39;,18, &#39;fontweight&#39;,&#39;b&#39;)&lt;br /&gt;
axis([0, num_juegos, 0, max(dinero_apostador)]);&lt;br /&gt;
&lt;br /&gt;
salida = [porciento_ganancia_apostador, porciento_perdida_casino, num_juegos];&lt;br /&gt;
&lt;br /&gt;
% fin del guión</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/248523504209009998/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2013/04/juego-de-volados-y-casinos-ricos.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/248523504209009998'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/248523504209009998'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2013/04/juego-de-volados-y-casinos-ricos.html' title='Juego de volados y casinos ricos'/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtVYkjHEpGkjt_cLyaghUydfqynaeLxUGN_WhPnL2VTSfxddW29fbFpwwf7DBv5DdNZwWlAh3cfWQ-A6_yNhCALM0WJ_IE3xvdVPWCPZM26yF-Cfj-pSsVJYst4Is7QOhbbuM1YyWbgfk/s72-c/casino_volados.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-2037555887155264682</id><published>2012-11-15T08:11:00.001-08:00</published><updated>2012-11-15T08:11:46.939-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Procesamiento de imágenes"/><title type='text'>¿Cuanto ruido puede resolver el proceso de correlación?</title><content type='html'>&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLAPQFdrfvCy8dBORNFsAvscfq1ZBPMQDY-pQLXvNuve2uBC7F_qoBfwk-FkOT92OkMBJoBVOXcoAaPtsrDgalrfR7Y_YAXjQePdjUA4ayrMfEm-3sYdPEZ-WyXW64HcaNDhvg6jGkQJ4/s1600/correlacion_ruido_imagenes.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLAPQFdrfvCy8dBORNFsAvscfq1ZBPMQDY-pQLXvNuve2uBC7F_qoBfwk-FkOT92OkMBJoBVOXcoAaPtsrDgalrfR7Y_YAXjQePdjUA4ayrMfEm-3sYdPEZ-WyXW64HcaNDhvg6jGkQJ4/s1600/correlacion_ruido_imagenes.png&quot; height=&quot;195&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Comportamiento del proceso de correlación ante un incremento del ruido aplicado a una imagen&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;b style=&quot;text-align: justify;&quot;&gt;Resumen&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Basado en &lt;a href=&quot;http://5minutosdematlab.blogspot.mx/2012/11/solucion-al-ejercicio-identificando.html&quot;&gt;una entrada anterior&lt;/a&gt;, me dio mucha curiosidad saber cómo se comportaría el proceso de correlación ante un incremento controlado de ruido en las imágenes. ¿Siempre tendrá un buen rendimiento?&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Así que seleccione una imagen – la original para este estudio  –  y le añadí ruido por medio de un Corel-Photo-Paint, para crear las imágenes “ruido”. Así,&amp;nbsp;cree&amp;nbsp;diez imágenes que presentaban ruido “gaussiano aleatorio“ en un intervalo de 0 a 100%, con incrementos de 10% para cada una. &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Después, le hice unas ligeras modificaciones al código original de identificación de imágenes por correlación, de modo que me mostrara la tendencia del comportamiento del promedio-de-los máximos-de-la-correlación de las imágenes en cuestión (deben ver el código para entender este proceso).&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
El resultado es la imagen que ilustra esta entrada. Cuando la imagen no presenta ruido, el proceso de correlación de la imagen consigo misma es igual a 1 (el valor ideal). En contraste, cuando la el ruido es máximo la correlación es aprox. 0.6. Más aún la tendencia de de este estudio es una línea recta; en otras palabras, el proceso de correlación es lineal en función del ruido añadido. Lo cual es una buena noticia para quienes &lt;a href=&quot;http://vicente1064.blogspot.mx/2008/12/ley-de-malus-ptica-y-la-fotoacstica.html&quot;&gt;usamos esta función para diversos estudios comparativos&lt;/a&gt;.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Sin embargo, falta hacer este estudio con ruido programado desde Matlab u otro software con mayor control de las variables del ruido añadido. De modo que sea claro cuál es el umbral cuantitativo que muestre cuando este proceso sea inadecuado.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Preguntas para pensar&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1) &lt;/b&gt;¿Cómo se comportara este proceso ante ruido armónico?&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;2) &lt;/b&gt;Por si sólo  este proceso no identifica el tipo de ruido. ¿Solo sirve para discriminar?, ¿Cómo se puede usar como filtro para mejorar la imagen?&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Ejercicios&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1) &lt;/b&gt;Use Matlab para añadir ruido a la imagen de modo sistemático. Analice los archivos generados. ¿Cómo se comporta el proceso de correlación ante el ruido blanco, el rosa, y otros? &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/2037555887155264682/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/11/cuanto-ruido-puede-resolver-el-proceso.html#comment-form' title='2 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/2037555887155264682'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/2037555887155264682'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/11/cuanto-ruido-puede-resolver-el-proceso.html' title='¿Cuanto ruido puede resolver el proceso de correlación?'/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLAPQFdrfvCy8dBORNFsAvscfq1ZBPMQDY-pQLXvNuve2uBC7F_qoBfwk-FkOT92OkMBJoBVOXcoAaPtsrDgalrfR7Y_YAXjQePdjUA4ayrMfEm-3sYdPEZ-WyXW64HcaNDhvg6jGkQJ4/s72-c/correlacion_ruido_imagenes.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-8000541483274120480</id><published>2012-11-13T07:50:00.000-08:00</published><updated>2012-11-15T08:11:59.799-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Curso 2012"/><category scheme="http://www.blogger.com/atom/ns#" term="Procesamiento de imágenes"/><category scheme="http://www.blogger.com/atom/ns#" term="Videos"/><title type='text'>Solución al ejercicio: Identificando huellas digitales simuladas con Matlab (video y script)</title><content type='html'>&lt;iframe allowfullscreen=&quot;allowfullscreen&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;http://www.youtube.com/embed/ax2-ybpPoDU&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuiXZITukcVD211cXqk_L_NqfFgAkRIWLyPHOGSKy0lLN-pjEj-1NCm2ktkkhFrQrVKyedLmiYANAhPn1FjC9BKTE2sN7FW9pIdnfRv9LPIsCJa3Z2xOOJiJtoiS0wOQZGy8QleCUkKN4/s1600/ejercicio_sospechosos_asesino.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuiXZITukcVD211cXqk_L_NqfFgAkRIWLyPHOGSKy0lLN-pjEj-1NCm2ktkkhFrQrVKyedLmiYANAhPn1FjC9BKTE2sN7FW9pIdnfRv9LPIsCJa3Z2xOOJiJtoiS0wOQZGy8QleCUkKN4/s400/ejercicio_sospechosos_asesino.png&quot; height=&quot;213&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Resultado gráfico del&amp;nbsp;análisis&amp;nbsp;de las&amp;nbsp;imágenes. El archivo núm. 14 corresponde al &amp;nbsp;análisis&amp;nbsp;de la misma imagen. De toda la base datos, el archivo núm. 3 es el que se parece más al archivo núm. 14&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Resumen&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Hace unos&amp;nbsp;días &lt;a href=&quot;http://5minutosdematlab.blogspot.mx/2012/10/ejercicio-jugando-al-detective-csi-con.html&quot;&gt;propuse un &lt;b&gt;ejercicio estilo el programa de televisión CSI&lt;/b&gt;&lt;/a&gt;. Dibuje unos cuantos &lt;b&gt;garabatos como si fueran huellas digitales&lt;/b&gt;; a una de ellos lo llamé &quot;&lt;b&gt;asesino&lt;/b&gt;&quot; al resto &quot;&lt;b&gt;sospechoso_num&lt;/b&gt;&quot; --a todas las&amp;nbsp;imágenes&amp;nbsp;les&amp;nbsp;añadí&amp;nbsp;un poco de ruido--. Pues bien. revisando la pequeña base de datos uno se puede dar cuenta que el archivo asesino coincide con la imagen del sospechoso número 3. El ejercicio trata de emplear código Matlab para hacer esta identificación.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Pueden existir muchas soluciones, aquí les muestre el uso de &lt;a href=&quot;http://en.wikipedia.org/wiki/Correlation_function&quot;&gt;la función correlación&lt;/a&gt;&amp;nbsp;estadística&amp;nbsp;&amp;nbsp;(&lt;a href=&quot;http://www.mathworks.com/help/stats/corr.html&quot;&gt;CORR&lt;/a&gt;, en Matlab) para hacer esta&amp;nbsp;identificación&amp;nbsp;automática. La&amp;nbsp;correlación&amp;nbsp;permite comparar señales, se usa mucho para &lt;a href=&quot;http://vicente1064.blogspot.mx/2011/03/5-ejemplos-sencillos-sobre-la.html&quot;&gt;estimar ajustes de curvas a datos experimentales&lt;/a&gt;, entre otras aplicaciones. En el caso ideal, cuando la imagen se compara consigo misma, la correlación es uno; cuando las&amp;nbsp;imágenes&amp;nbsp;son totalmente dispares, la&amp;nbsp;correlación&amp;nbsp;vale cero. En este caso, los&amp;nbsp;análisis&amp;nbsp;que más se aproximen a 1 indican mayor probabilidad de tener&amp;nbsp;identificación&amp;nbsp;de nuestro &quot;asesino&quot;.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Ahora bien, nos apoyamos en la obtención del máximo (&lt;a href=&quot;http://www.mathworks.com/help/matlab/ref/max.html&quot;&gt;MAX&lt;/a&gt; en Matlab) y luego del promedio (&lt;a href=&quot;http://www.mathworks.com/help/matlab/ref/mean.html&quot;&gt;MEAN&lt;/a&gt; en Matlab) para tener el valor más representativo de la mayor variación que se puede presentar en el&amp;nbsp;análisis.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
La figura que ilustra este &lt;i&gt;post&lt;/i&gt; muestra el &amp;nbsp;resultado del &lt;i&gt;script&lt;/i&gt; --que se presenta al final de la entrada-- . Podemos ver que la comparación de la imagen&amp;nbsp;consigo misma&amp;nbsp;da 1, y que el archivo 3 es el que más se acerca al valor ideal. Mientras que los demás valores&amp;nbsp;están&amp;nbsp;bastante alejados del valor del archivo núm. 3. Por lo cual la identificación es exitosa.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Preguntas para pensar&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1) &lt;/b&gt;Menciona otras aplicaciones de la&amp;nbsp;función&amp;nbsp;de correlación.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;2)&lt;/b&gt; ¿Mediante que otra función se puede hacer el&amp;nbsp;análisis&amp;nbsp;de&amp;nbsp;identificación?&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Ejercicios&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1)&lt;/b&gt; A la base de datos de imagenes asocie una base datos con nombres&amp;nbsp;ficticios. (Por ejemplo: alfa, beta, gamma, etc.)&amp;nbsp; &amp;nbsp;Modifique el guión para que la pantalla le de el nombre del sospechoso más probable.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;2)&lt;/b&gt; Dibuje sus propios garabatos y haga experimentos. Por ejemplo, a una imagen añada diferentes cantidades y clases de ruido. &amp;nbsp;Identifique cuales son los limites de este&amp;nbsp;análisis.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;3)&lt;/b&gt; Sí las&amp;nbsp;imágenes&amp;nbsp;se giran, la&amp;nbsp;identificación&amp;nbsp;es valida. Haga experimentos.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;4)&lt;/b&gt; La&amp;nbsp;función&amp;nbsp;correlación&amp;nbsp;es la que más tiempo consume en el guion. ¿Cómo puede aumentar el tiempo de calculo para hacer más rápido el proceso?&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
% INICIO DE GUION EN MATLAB&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
%Cierra todas las ventanas emergentes, limpia la memoria y la pantalla&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
close all; clear; clc;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Ases = imread(&#39;asesino&#39;,&#39;jpeg&#39;); %Lee la imágen y la asocia a una matriz&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
G = fft2(Ases); %Calcula la transformada de fourier en 2D de la imagen&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
m(13) = mean(max(corr(G,G))); %Se compara la imagen consigo misma&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
% Con este for cargamos las imagenes, las procesamos y obtenemos un valor&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
% significativo&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
for n =1:12&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
nom_arch=[&#39;sospechoso&#39;, num2str(n)]; %esta cadena de caracteres cambia como lo hace n&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Sosp =imread(nom_arch, &#39;jpeg&#39;); %se carga la imagen a trabajar&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
F = fft2(Sosp); % se obtiene la trasformada de Fourier&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
m(n) = mean(max(corr(F,G))); % Se comparara la imagen con un&amp;nbsp;estándar&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
%m(i).- Se guarda el valor del i-ésimo sospechoso en la entrada m(i)&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
end&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
% Se define el contador x, para graficar&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
x = 1:13;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
% Grafica de x, m. Utilizo puntos rojo y lineas verticales azules&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
h = stem(x,m,&#39;fill&#39;,&#39;--&#39;);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
set(get(h,&#39;BaseLine&#39;),&#39;LineStyle&#39;,&#39;:&#39;)&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
set(h,&#39;MarkerFaceColor&#39;,&#39;red&#39;)&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
%Formato de la gráfica&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
xlabel(&#39;Etiqueta para el de sospechoso (número)&#39;);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
ylabel(&#39;Correlación entre imagenes&#39;);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
axis([0 14 0 1.1]);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
% clear&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
% clc&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
%fin del script&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/8000541483274120480/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/11/solucion-al-ejercicio-identificando.html#comment-form' title='11 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/8000541483274120480'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/8000541483274120480'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/11/solucion-al-ejercicio-identificando.html' title='Solución al ejercicio: Identificando huellas digitales simuladas con Matlab (video y script)'/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/ax2-ybpPoDU/default.jpg" height="72" width="72"/><thr:total>11</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-8309911248607026247</id><published>2012-11-05T20:44:00.000-08:00</published><updated>2012-11-05T20:44:16.654-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="material extra"/><title type='text'>Cómo hacer interfaces gráficas para usuario (GUI) con guide de Matlab</title><content type='html'>&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhY7nxAoA-5rVF6nzoZg8_th_YSnAVYxyNnklckgH7eyttvg9BOThgBVfc_01KUkyi0saxky-i7FLRIHFrhbFY3z-LkPN8sVKj_c379sxHXT3ivVZQDvMsXxRp5c672SLITgajTpyQpE4/s1600/usuario_feliz_computadora.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhY7nxAoA-5rVF6nzoZg8_th_YSnAVYxyNnklckgH7eyttvg9BOThgBVfc_01KUkyi0saxky-i7FLRIHFrhbFY3z-LkPN8sVKj_c379sxHXT3ivVZQDvMsXxRp5c672SLITgajTpyQpE4/s1600/usuario_feliz_computadora.jpg&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Imagen vía: &lt;a href=&quot;http://smallbiztechnology.com/archive/2008/04/bad-weather-missing-work-and-t.html/&quot;&gt;smallbiz&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Del el documento de &lt;a href=&quot;http://www.slideshare.net/lsiero1/guide-4512592&quot;&gt;CONATEC 2002&lt;/a&gt; hemos visto varios ejemplos del uso de GUIDE para hacer GUI en Matlab, espero que puedan hacer TODOS los ejemplos.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/8309911248607026247/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2011/11/como-hacer-interfaces-graficas-para.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/8309911248607026247'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/8309911248607026247'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2011/11/como-hacer-interfaces-graficas-para.html' title='Cómo hacer interfaces gráficas para usuario (GUI) con guide de Matlab'/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhY7nxAoA-5rVF6nzoZg8_th_YSnAVYxyNnklckgH7eyttvg9BOThgBVfc_01KUkyi0saxky-i7FLRIHFrhbFY3z-LkPN8sVKj_c379sxHXT3ivVZQDvMsXxRp5c672SLITgajTpyQpE4/s72-c/usuario_feliz_computadora.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-2765819851536910670</id><published>2012-10-26T10:03:00.001-07:00</published><updated>2012-10-26T10:04:02.639-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Codigos"/><category scheme="http://www.blogger.com/atom/ns#" term="Videos"/><title type='text'>Código Matlab para hacer un contador de franjas de interferencia</title><content type='html'>&lt;iframe allowfullscreen=&quot;allowfullscreen&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;http://www.youtube.com/embed/JPDRWeKKNKE&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Resumen&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Esta es una aplicación sencilla de Matlab para analizar imágenes. Se trata de cargar la imagen segmentada de un interferograma - sus franjas de interferencia deben ser verticales -. La imagen se transforma en matriz, se colapsa en vector, y se transforma en datos de ceros y unos. Al barrer la matriz se puede contar el numero de transiciones ,el cual es proporcional al número de franjas.&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Muchos de los comandos que se emplean en este ejemplo los hemos explicado en anteriores entradas, y se mencionan sus funciones en el video. &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Descarga el archivo: &lt;a href=&quot;https://docs.google.com/open?id=0B0QZOy9azJfnN3ZTRmN0QWYzQ0U&quot;&gt;contador_de_franjas.rar&lt;/a&gt; que contiene el código, las imagenes originales, y las imágenes segmentedas para que puedas hacer los ejercicios propuestos.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Ejercicios&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1)&lt;/b&gt; Optimice la velocidad de ejecución de este código. Comience eliminando las  lineas de código que  no se usan más adelante.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;2)&lt;/b&gt; ¿Como se pueden eliminar los artefactos de ruido?, de modo que se mejore el desempeño del conteo de franjas&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;3)&lt;/b&gt; Transforme este guión en una función&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;4)&lt;/b&gt;  Integre a video este código (esta tarea es avanzada)&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/2765819851536910670/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/10/codigo-matlab-para-hacer-un-contador-de.html#comment-form' title='3 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/2765819851536910670'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/2765819851536910670'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/10/codigo-matlab-para-hacer-un-contador-de.html' title='Código Matlab para hacer un contador de franjas de interferencia'/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/JPDRWeKKNKE/default.jpg" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-1999493003175772075</id><published>2012-10-25T20:27:00.000-07:00</published><updated>2012-10-25T20:27:46.968-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Curso 2012"/><title type='text'>Presentación de funciones de transferencia en Matlab</title><content type='html'>Estas son notas que hemos visto en clase. La idea es que practiquen sus habilidades para hacer código en Matlab.&lt;br /&gt;
&lt;br /&gt;
Si ven un error en la presentación, dejen un comentario ;)&lt;br /&gt;
&lt;br /&gt;
&lt;iframe src=&quot;http://www.slideshare.net/slideshow/embed_code/14892143&quot; width=&quot;427&quot; height=&quot;356&quot; frameborder=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; scrolling=&quot;no&quot; style=&quot;border:1px solid #CCC;border-width:1px 1px 0;margin-bottom:5px&quot; allowfullscreen&gt; &lt;/iframe&gt; &lt;div style=&quot;margin-bottom:5px&quot;&gt;&lt;strong&gt; &lt;a href=&quot;http://www.slideshare.net/vicentz/funciones-de-transferencia-analgicas&quot; title=&quot;Funciones de transferencia analógicas&quot; target=&quot;_blank&quot;&gt;Funciones de transferencia analógicas&lt;/a&gt; &lt;/strong&gt; from &lt;strong&gt;&lt;a href=&quot;http://www.slideshare.net/vicentz&quot; target=&quot;_blank&quot;&gt;Vicente Torres&lt;/a&gt;&lt;/strong&gt; &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/1999493003175772075/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/10/presentacion-de-funciones-de.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/1999493003175772075'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/1999493003175772075'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/10/presentacion-de-funciones-de.html' title='Presentación de funciones de transferencia en Matlab'/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-1969668981136219778</id><published>2012-10-25T13:24:00.000-07:00</published><updated>2012-11-15T08:12:11.663-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Curso 2012"/><category scheme="http://www.blogger.com/atom/ns#" term="Procesamiento de imágenes"/><title type='text'>Ejercicio: Jugando al detective CSI con Matlab</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeBTOIevOXzGBVKKZmRhqgaV-_ouzrElhjJcYw7nMDWrl4HZD-NRwSFkzn5pCCvWdZjmHRHKrFGx-4iyxcQxO25IfHe0NxPdO07IPORso-Eea8VgCzdnkE9hmu8zXPz63p4MtbsHocONk/s1600/csi_matlab.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeBTOIevOXzGBVKKZmRhqgaV-_ouzrElhjJcYw7nMDWrl4HZD-NRwSFkzn5pCCvWdZjmHRHKrFGx-4iyxcQxO25IfHe0NxPdO07IPORso-Eea8VgCzdnkE9hmu8zXPz63p4MtbsHocONk/s200/csi_matlab.jpg&quot; height=&quot;178&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
He creado una &lt;a href=&quot;https://docs.google.com/open?id=0B0QZOy9azJfnaFRZY0dWeDRKT00&quot;&gt;pequeña base de datos de varias&amp;nbsp;imágenes de garabatos&lt;/a&gt;. A una de ellas le he llamado asesino, el resto las he llamado sospechoso. El ejercicio consiste en escribir código Matlab para identificar de las imagenes de sospechosos al &amp;nbsp;patrón que más se parezca a la imagen que llame asesino.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Las&amp;nbsp;imágenes&amp;nbsp;contienen un poco de ruido gaussiano, por lo cual hay que filtrar ese ruido. Dependiendo de su desempeño, se puede hacer más interesante este ejercicio.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Por su puesto estos temas, en la vida real, son más complicados. Las bases de datos son más grandes, se deben de identificar varios puntos de coincidencia, el ruido es mucho, mucho mayor. Con todo, es un buen ejercicio.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
En caso de tener cualquier clase de duda, escriban un comentario en el blog.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/1969668981136219778/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/10/ejercicio-jugando-al-detective-csi-con.html#comment-form' title='2 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/1969668981136219778'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/1969668981136219778'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/10/ejercicio-jugando-al-detective-csi-con.html' title='Ejercicio: Jugando al detective CSI con Matlab'/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeBTOIevOXzGBVKKZmRhqgaV-_ouzrElhjJcYw7nMDWrl4HZD-NRwSFkzn5pCCvWdZjmHRHKrFGx-4iyxcQxO25IfHe0NxPdO07IPORso-Eea8VgCzdnkE9hmu8zXPz63p4MtbsHocONk/s72-c/csi_matlab.jpg" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-8952176876638663998</id><published>2012-10-23T07:06:00.002-07:00</published><updated>2012-10-25T13:24:54.549-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Curso 2012"/><title type='text'>Trabajo de Matlab y video.</title><content type='html'>Pueden consultar &lt;a href=&quot;https://docs.google.com/open?id=0B0QZOy9azJfnMzRrTG5CWVg4Rkk&quot;&gt;el documento de nuestra práctica de integración de video y Matlab&lt;/a&gt;. &lt;br /&gt;
&lt;br /&gt;
En caso de tener dudas, escriban un mensaje en este blog.&lt;br /&gt;
&lt;br /&gt;
&lt;iframe height=&quot;480&quot; src=&quot;https://docs.google.com/file/d/0B0QZOy9azJfnMzRrTG5CWVg4Rkk/preview&quot; width=&quot;500&quot;&gt;&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/8952176876638663998/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/10/trabajo-de-matlab-y-video.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/8952176876638663998'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/8952176876638663998'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/10/trabajo-de-matlab-y-video.html' title='Trabajo de Matlab y video.'/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-5000951796124227761</id><published>2012-10-03T09:25:00.001-07:00</published><updated>2012-10-25T13:25:05.431-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Curso 2012"/><title type='text'>Tres ejemplos de matemáticas discretas </title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
Pueden consultar los post relacionados con los temas que vimos el&amp;nbsp;día&amp;nbsp;de hoy:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1)&amp;nbsp;&lt;/b&gt;&lt;a href=&quot;http://5minutosdematlab.blogspot.mx/2011/09/codigo-y-ejemplos-con-diferentes.html&quot;&gt;Filtro pasa bajas que usa promedio ponderado&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;2)&lt;/b&gt;&amp;nbsp;&lt;a href=&quot;http://5minutosdematlab.blogspot.mx/2011/09/codigo-para-encontrar-la-senal.html&quot;&gt;Filtro basado en transformada de Fourier y localización del &amp;nbsp;pico principal&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;3)&lt;/b&gt; &lt;a href=&quot;http://5minutosdematlab.blogspot.mx/2011/09/comparacion-del-desempeno-de-un-filtro.html&quot;&gt;Filtro utilizando la convolución &amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Por su puesto, revisen a detalle el excelente &lt;a href=&quot;http://5minutosdematlab.blogspot.mx/2011/09/codigo-matlab-para-acondicionar-y.html&quot;&gt;ejemplo de filtraje de electrocardiogramas&lt;/a&gt;.&amp;nbsp;Finalmente, consulten &lt;a href=&quot;http://5minutosdematlab.blogspot.mx/2011/09/codigo-para-obtener-la-primera-derivada.html&quot;&gt;el código para hacer la primera derivada&lt;/a&gt;. Uds. pueden hacer el código para hacer la primera integral de una función discreta.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
¿Me falto mencionar algo? Dejen un comentario si necesitan más información u&amp;nbsp;omití&amp;nbsp;algo importante.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/5000951796124227761/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/10/dos-ejemplos-de-matematicas-discretas.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/5000951796124227761'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/5000951796124227761'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/10/dos-ejemplos-de-matematicas-discretas.html' title='Tres ejemplos de matemáticas discretas '/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-1150702872765227752</id><published>2012-09-13T14:37:00.000-07:00</published><updated>2012-09-13T14:37:03.313-07:00</updated><title type='text'>Presentación y ejercicio de la técnica  Montecarlo </title><content type='html'>Ya pueden consultar el &lt;a href=&quot;http://5minutosdematlab.blogspot.mx/2011/10/presentacion-introduccion-la-tecnica.html&quot;&gt;post con la presentación de la técnica Montercarlo&lt;/a&gt;. Además puedes consultar &lt;a href=&quot;http://5minutosdematlab.blogspot.mx/2011/10/ejemplo-del-uso-de-la-tecnica.html&quot;&gt;el post que tiene&amp;nbsp;ejemplo &lt;/a&gt;que te ayudaran a profundizar en el tema.</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/1150702872765227752/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/09/presentacion-y-ejercicio-de-la-tecnica.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/1150702872765227752'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/1150702872765227752'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/09/presentacion-y-ejercicio-de-la-tecnica.html' title='Presentación y ejercicio de la técnica  Montecarlo '/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-1317512818502927083</id><published>2012-09-07T10:17:00.002-07:00</published><updated>2012-09-09T16:29:57.795-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Actividades"/><category scheme="http://www.blogger.com/atom/ns#" term="Curso 2012"/><title type='text'>Jugando con perfiles e histogramas en imágenes de Matlab</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Entregar reporte de resultados, DE ESTA ENTRADA, antes del 19 &amp;nbsp;de septiembre &amp;nbsp;2012&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Las imágenes de prueba están en C:\MATLAB\toolbox\images\imdemos&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Pruebe las siguientes funciones:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioXezRq8HMJ104hqjmHXpbgN3_zEqbTYmTZMB7HDZkz3RBHyS-Oyf4HIlxAkl6dXZ9vA9TRo9uSlWY9VG-24cPMXfgNZLR0qa4Qi7abvykHCYXAZXKx6cLQbG1N-ffxdAEr-QHLWILWJM/s1600/bacteria.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioXezRq8HMJ104hqjmHXpbgN3_zEqbTYmTZMB7HDZkz3RBHyS-Oyf4HIlxAkl6dXZ9vA9TRo9uSlWY9VG-24cPMXfgNZLR0qa4Qi7abvykHCYXAZXKx6cLQbG1N-ffxdAEr-QHLWILWJM/s1600/bacteria.jpg&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;imagen bacteria, archivo&lt;br /&gt;
en escala de grises&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div&gt;
X = imread(&#39;bacteria.jpg&#39;,&#39;JPG&#39;); &amp;nbsp; &amp;nbsp; % probar al menos tres imágenes distintas&lt;/div&gt;
&lt;div&gt;
image(X);&lt;/div&gt;
colormap(map);&lt;br /&gt;
colormap(hot); colorbar;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
pause&lt;br /&gt;
image(X);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
liney=X(:,100); &amp;nbsp; &amp;nbsp; % column profile (vert)&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
linex=X(60,:); &amp;nbsp; &amp;nbsp; &amp;nbsp; % row profile (horiz)&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
hold on; plot(linex);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDMUbZEhD-j8V5WN6Uin0lF_hIYGk6Hs7MU02Xb__DEsKB7gKGHCBlTlrdxg2BXu4x2gXLBAhFLeg5b_wydmi6GYslzL74mT3VnBI1EDAc3dCXdZ4s2bCEJtlRvDz6qRdyjwwI4pOVntI/s1600/resultado_img_matlab.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDMUbZEhD-j8V5WN6Uin0lF_hIYGk6Hs7MU02Xb__DEsKB7gKGHCBlTlrdxg2BXu4x2gXLBAhFLeg5b_wydmi6GYslzL74mT3VnBI1EDAc3dCXdZ4s2bCEJtlRvDz6qRdyjwwI4pOVntI/s320/resultado_img_matlab.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Resultado de la primera rutina&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;b&gt;1.&lt;/b&gt; Pruebe otros perfiles sin exceder las dimensiones de la imagen (recordar “size(X)”) e interprete dichos perfiles en función de la imagen&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;2.&lt;/b&gt; &amp;nbsp;Los valores de gris de los píxeles de una imagen son una población cuya distribución (frecuencia) permite caracterizar ciertas propiedades de la imagen, sin preservar información espacial (aunque depende de dónde se toman las muestras. &amp;nbsp; Pruebe las funciones de histograma de una señal, pero ahora en una imagen. &amp;nbsp; Implemente usted su propia función para calcular un histograma y grafiquelo en diferentes escalas.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Sugerencia (ejercicio: corregir índices definiendo por ejemplo H como subvector de otra matriz ):&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
% X se define como arriba: &amp;nbsp;una matriz que contiene la imagen.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
H=zeros(256,1); &amp;nbsp; &amp;nbsp;% iniciar vector de histograma a 0&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
[m,n] = size(X); &amp;nbsp; &amp;nbsp;% obtener dimensiones&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
for i=1:m&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp; for j=1:n&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;H(X(i,j)+1) = H(X(i,j)+1)+1; &amp;nbsp; % usar datos como direcciones para contra frecuencias&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp; end&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
end&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
plot(H);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;3.&lt;/b&gt; &amp;nbsp;Calcule ahora su histograma en escala logarítmica, muestreando la imagen de manera uniforme; pruebe la función random. &amp;nbsp; Observe los detalles del histograma y pruebe otras escalas. &amp;nbsp;Comente sus observaciones.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;4.&lt;/b&gt; &amp;nbsp;Si N es el total de pixeles, y se muestrean M.&amp;nbsp;Calcule histograma de zonas de interés (un rectángulo que contenga las bacterias, por ejemplo). &amp;nbsp;Compare con histogramas del fondo en distintas áreas. &amp;nbsp;¿Cómo se relacionan con el histograma global? &amp;nbsp; Repita 4. para una zona de interés (no del fondo). &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;6.&lt;/b&gt; Compara la implementación de arriba con las funciones de histograma predefinidas en Matlab (úselas). &lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;7.&lt;/b&gt; &amp;nbsp;Aumente el intervalo dinámico de los valores de gris (o sea el contraste) usando la información del histograma (recordar lo que se vio en clase), en uno global y en dos locales. &amp;nbsp;Para esto será necesario modificar los valores de gris de acuerdo al histograma.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;8.&lt;/b&gt; &amp;nbsp; ¿Cómo definir y almacenar &amp;nbsp;su propia paleta de colores? &amp;nbsp;Diseñe una que vaya de café obscuro a color crema y de crema azul claro, de azul claro a verde.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/1317512818502927083/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/09/jugando-con-perfiles-e-histogramas-en.html#comment-form' title='7 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/1317512818502927083'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/1317512818502927083'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/09/jugando-con-perfiles-e-histogramas-en.html' title='Jugando con perfiles e histogramas en imágenes de Matlab'/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioXezRq8HMJ104hqjmHXpbgN3_zEqbTYmTZMB7HDZkz3RBHyS-Oyf4HIlxAkl6dXZ9vA9TRo9uSlWY9VG-24cPMXfgNZLR0qa4Qi7abvykHCYXAZXKx6cLQbG1N-ffxdAEr-QHLWILWJM/s72-c/bacteria.jpg" height="72" width="72"/><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-2121351242791790928</id><published>2012-09-07T07:54:00.000-07:00</published><updated>2012-09-07T10:22:14.995-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Curso 2012"/><category scheme="http://www.blogger.com/atom/ns#" term="gráficas"/><category scheme="http://www.blogger.com/atom/ns#" term="Temas básicos"/><category scheme="http://www.blogger.com/atom/ns#" term="Videos"/><title type='text'>Cómo transformar una figura de Matlab en una imagen portable.  </title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&quot;allowfullscreen&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;http://www.youtube.com/embed/Ke5E26PGNxg&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Resumen&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
En esta ocasión se muestran las bases para que nuestras figuras en Matlab se exporten como archivos de imagen y se puedan incorporar en un procesador de textos.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Básicamente, existen cuatro caminos para exportar:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1)  El copy-page&lt;/b&gt;; en la barra de menús de la imagen, damos clic en Edit y luego en Copy figure. Ya después podemos pegar nuestra información en otro programa, tal vez powerpoint.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;2) Salvar como.&lt;/b&gt; Utilizando la interface gráfica de la figura Matlab, podemos cómodamente salvar nuestra figura en diversos formatos de imagen (png, pdf, jpg, etc.).  Únicamente hay que seguir las instrucciones&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;3) Uso del &lt;a href=&quot;http://www.mathworks.com/help/techdoc/ref/print.html&quot;&gt;comando print&lt;/a&gt;. &lt;/b&gt;Este comando es muy versátil y permite guarda las imágenes en varios formatos, controlar la calidad de pdi de la imagen e incluso automatizar el proceso de guardar-nombrar archivos. Además de ser el de mayor calidad.  Mejor aún, utilizando previamente los comandos:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Set(gcf, ‘InvertHardcopy’, ‘off’) &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Así, se preserva el color del fondo que nosotros escogimos previamente para la figura. &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;4) Impresión de pantalla.&lt;/b&gt; En el video omitimos esta opción para salvar las imágenes, pues no es propio de Matlab. El botón de ImprPant es muy general y depende de la resolución de tu monitor, suele mostrar elementos innecesarios que se deberían de corregir en un programa que manipule imágenes. Cuando se trabaja con muchas imágenes y se busca la mejor calidad, este camino se debe evitar&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Contar con gráficas de alta calidad visual y de datos es vital para que nuestra publicación, tesis o trabajo escolar sea aprobado por los revisores; por ello no se debe descuidar la presentación de nuestras imágenes.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Preguntas para pensar&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1)&lt;/b&gt; ¿Qué determina que la imagen sea de alta calidad?&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;2)&lt;/b&gt; ¿Por qué usar 300 dpi en esta clase de imágenes?, ¿Siempre es así?&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Ejercicios &lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1)&lt;/b&gt; Introduzca en un ciclo for el comando print, de modo que obtenga 10 imágenes secuenciadas de una senoidal a la que se le varia la frecuencia o la amplitud.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/2121351242791790928/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/09/como-transformar-una-figura-de-matlab.html#comment-form' title='2 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/2121351242791790928'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/2121351242791790928'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/09/como-transformar-una-figura-de-matlab.html' title='Cómo transformar una figura de Matlab en una imagen portable.  '/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/Ke5E26PGNxg/default.jpg" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-1865730444398721050</id><published>2012-09-03T08:58:00.001-07:00</published><updated>2012-09-03T08:58:32.025-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Codigos"/><category scheme="http://www.blogger.com/atom/ns#" term="Curso 2012"/><category scheme="http://www.blogger.com/atom/ns#" term="gráficas"/><title type='text'>Juntas, pero no revueltas: sub-gráficas en una misma figura de Matlab</title><content type='html'>&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ1GFZx5BeArjBezbScCbvbPwnZDCfW3fo52_9fNL6EotqkKyzwSlTu3G4Iw6nIYO3HfuRwixRBP6GziMDIESNxyCuRoYLuxLOaYNkMStwt9lwUoAc-0xGSWU478XIy-fWRmH4NzIx01o/s1600/ejercicio_matlab_graficas.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;150&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ1GFZx5BeArjBezbScCbvbPwnZDCfW3fo52_9fNL6EotqkKyzwSlTu3G4Iw6nIYO3HfuRwixRBP6GziMDIESNxyCuRoYLuxLOaYNkMStwt9lwUoAc-0xGSWU478XIy-fWRmH4NzIx01o/s200/ejercicio_matlab_graficas.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Ejemplo del uso de subplot&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
El comando de Matlab &lt;b&gt;&lt;a href=&quot;http://www.mathworks.com/help/matlab/ref/subplot.html&quot;&gt;subplot&lt;/a&gt;&lt;/b&gt; es lo suficientemente versátil para darle sendos ejes y características adicionales a las gráficas que coloquemos en una misma imagen.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Efectivamente, basta con indicar como se compondrá la matriz de la imagen &lt;i&gt;(a,b)&lt;/i&gt; y que espacio &lt;i&gt;p&lt;/i&gt; ocupará cada una de las gráficas; es decir,  subplot (m, n, p) hace la división del espacio de la figura. Matlab asignara el espacio con en paneles regulares para cada gráfica. Este es un ejemplo simple de una rutina aplicada una figura compuesta de 2 gráficas.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfg1MHGcuIsbXi4xWHQDoTRbzWJEIyUpucJRdABxu1CKe6jU_8ls_sxJQWywNT0yiyRrYw7pF3u5BRHpU2d_EePvu2npSOBeK4R94oI-VteZFwtNB8zYVdpBUNnzywH06BKRDZDukP8Gs/s1600/subplot_matlab.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;191&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfg1MHGcuIsbXi4xWHQDoTRbzWJEIyUpucJRdABxu1CKe6jU_8ls_sxJQWywNT0yiyRrYw7pF3u5BRHpU2d_EePvu2npSOBeK4R94oI-VteZFwtNB8zYVdpBUNnzywH06BKRDZDukP8Gs/s200/subplot_matlab.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Asignación simple de paneles&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
x= 1:0.1:2*pi;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
subplot(2,1,1), plot(x)&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
subplot(2,1,2), plot(sin(x))&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
En general, el comando subplot brinda una figura de configuración simétrica de paneles, que son donde se colocan las gráficas. Y cada panel es independiente de los otros. Sin embargo, si el parámetro &lt;i&gt;p&lt;/i&gt; es una matriz, entonces se puede ocupar más de un panel para una gráfica. Por tanto, en una misma figura se puede colocar una gráfica grande y otras más pequeñas. Por ejemplo usando el siguiente código:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrHJrn1iz-0m58uYljVMvZ7b9-OJWL8OgTUbOT6PhXWNtuzpxZhTfVZP4cB2oYK-BOLgxnfsqosesH01x_svidjzQoE_w-6d_w1sM2miV52QB8eECqOfZdpL91HkFwGlx6cJnW4xT1RiQ/s1600/subplot_matlab_asimetrico.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;191&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrHJrn1iz-0m58uYljVMvZ7b9-OJWL8OgTUbOT6PhXWNtuzpxZhTfVZP4cB2oYK-BOLgxnfsqosesH01x_svidjzQoE_w-6d_w1sM2miV52QB8eECqOfZdpL91HkFwGlx6cJnW4xT1RiQ/s200/subplot_matlab_asimetrico.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Asignación&amp;nbsp;asimétrica&amp;nbsp;de paneles&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
x= 1:0.1:2*pi;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
subplot(2,2,[1 2]); plot(sin(x))&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
subplot(2,2,3); plot(log(x))&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
subplot(2,2,4); plot(exp(x))&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Finalmente, hay que destacar que se puede utilizar el subplot dentro de ciclos de programación, de forma que se pueden automatizar colecciones de imágenes que siguen una línea de historica. Por ejemplo:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM4MG4yEePDFVoaIa8iYpBwnRoEgt2UkEi0wJ4o7ERsGULMld6E0_JIQWwJhbyE06zY6U7is1n-YfyBamyxw22aOkfPLdkrQA4lsyWDlsxp23pSaiTcV1JD5Wq2r_gyWxus6-VNyA7vKE/s1600/subplot_graf_aleatoria_for.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;191&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM4MG4yEePDFVoaIa8iYpBwnRoEgt2UkEi0wJ4o7ERsGULMld6E0_JIQWwJhbyE06zY6U7is1n-YfyBamyxw22aOkfPLdkrQA4lsyWDlsxp23pSaiTcV1JD5Wq2r_gyWxus6-VNyA7vKE/s200/subplot_graf_aleatoria_for.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Ejemplo del uso de &amp;nbsp;subplot&lt;br /&gt;
en un ciclo for&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
y = zeros(4,15); % se inicializa un vector, para ser más eficiente&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
for k = 1:4 % seran cuatro colecciones de datos&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
y(k,:) = rand(1,15); % se crea un vector de 15 elementos aleatorios&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
subplot(2, 2, k) % el índice se usa para dar orden a la secuencia de gráficas &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
plot(y(k,:)); % se hace la gráfica&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
end&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Precauciones&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Utilizando scripts, solamente se pueden crear estas gráficas cuando ya se cuenta con la matriz completa. En otro caso hay que utilizar comandos como drawnow, del que ya &lt;a href=&quot;http://5minutosdematlab.blogspot.mx/2012/08/dibujando-graficas-como-si-fueran.html&quot;&gt;anteriormente hemos mostrado unos ejemplos&lt;/a&gt;.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Preguntas para pensar&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1) &lt;/b&gt;Describa un ejemplo especifico donde los subplot en un ciclo for son aplicados&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Ejercicios&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1) &lt;/b&gt;Obtenga la siguiente imagen utilizando diferentes comandos de Matlab&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ1GFZx5BeArjBezbScCbvbPwnZDCfW3fo52_9fNL6EotqkKyzwSlTu3G4Iw6nIYO3HfuRwixRBP6GziMDIESNxyCuRoYLuxLOaYNkMStwt9lwUoAc-0xGSWU478XIy-fWRmH4NzIx01o/s1600/ejercicio_matlab_graficas.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ1GFZx5BeArjBezbScCbvbPwnZDCfW3fo52_9fNL6EotqkKyzwSlTu3G4Iw6nIYO3HfuRwixRBP6GziMDIESNxyCuRoYLuxLOaYNkMStwt9lwUoAc-0xGSWU478XIy-fWRmH4NzIx01o/s400/ejercicio_matlab_graficas.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Ejercicio de esta entrada&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/1865730444398721050/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/09/juntas-pero-no-revueltas-sub-graficas.html#comment-form' title='2 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/1865730444398721050'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/1865730444398721050'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/09/juntas-pero-no-revueltas-sub-graficas.html' title='Juntas, pero no revueltas: sub-gráficas en una misma figura de Matlab'/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ1GFZx5BeArjBezbScCbvbPwnZDCfW3fo52_9fNL6EotqkKyzwSlTu3G4Iw6nIYO3HfuRwixRBP6GziMDIESNxyCuRoYLuxLOaYNkMStwt9lwUoAc-0xGSWU478XIy-fWRmH4NzIx01o/s72-c/ejercicio_matlab_graficas.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-8774892312342487126</id><published>2012-08-30T08:05:00.001-07:00</published><updated>2012-08-30T08:05:57.474-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="gráficas"/><category scheme="http://www.blogger.com/atom/ns#" term="Temas avanzados"/><title type='text'>Dibujando gráficas como si fueran animaciones en Matlab </title><content type='html'>&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4tIdiqUhPsMZ5kwIlnuPsJZxnz3b-TDcAgTyXvhtVzSrN45k4vq6gIs8qtKZPST4ZZdr6-RXImYNeyrFSEVlHW1pRWgeHRAh9PkcBslRQY_TqqORmwgqaFKmq8uH8brKC08vIThUJYeo/s1600/dibujo_tiempo_real_animacion_matlab.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4tIdiqUhPsMZ5kwIlnuPsJZxnz3b-TDcAgTyXvhtVzSrN45k4vq6gIs8qtKZPST4ZZdr6-RXImYNeyrFSEVlHW1pRWgeHRAh9PkcBslRQY_TqqORmwgqaFKmq8uH8brKC08vIThUJYeo/s1600/dibujo_tiempo_real_animacion_matlab.jpg&quot; height=&quot;146&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://aixa.ugr.es/escher/table.html&quot;&gt;Manos dibujando&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Matlab permite fácilmente crear gráficas; pero ¿qué pasa cuando queremos hacer una animación de esa gráfica? Por ejemplo, ir presentado cómo se produce la trayectoria de un cuerpo en movimiento. Con animaciones esta tipo de gráficas son espectaculares en cualquier presentación. En &lt;a href=&quot;http://5minutosdematlab.blogspot.mx/2012/03/como-hacer-la-animacion-de-una-senoidal.html&quot;&gt;una entrada anterior&lt;/a&gt; trate un poco sobre este tema utilizando fotogramas.&lt;br /&gt;
&lt;br /&gt;
Aquí, presentare ejemplos donde no se crea video.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Ingenuamente podemos usar un código simple, como el siguiente. &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
figure(1);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
for i=1:1000&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
T(i)=cos(i);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
plot(T);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
end&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Efectivamente, aunque no aprovechamos la ventaja de la preasginación de memoria, la idea es que no es importante la velocidad del cálculo, sino que se cuente con la construcción dinámica de la curva; por ello, el comando plot tiene ir dentro del ciclo for.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Sin embargo, hasta este punto, el código es inútil. Pues la reserva de memoria de los cálculos es independiente y asíncrona de la memoria gráfica. Es decir la gráfica se&amp;nbsp;producirá&amp;nbsp;cuando se cuente con el vector completo.&amp;nbsp;&amp;nbsp;La solución es insertar un comando que actualice todas las ventanas ese comando es &lt;b&gt;&lt;a href=&quot;http://www.mathworks.com/help/techdoc/ref/drawnow.html&quot;&gt;drawnow&lt;/a&gt;&lt;/b&gt;.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Con todo, nuestro código se puede estar ejecutando muy rápido; por lo que hay que añadir dentro del código una pausa (&lt;b&gt;&lt;a href=&quot;http://www.mathworks.com/help/techdoc/ref/pause.html&quot;&gt;comando pause&lt;/a&gt;&lt;/b&gt;) al que se le puede controlar el tiempo de ejecución. Digamos que esperamos .3 segundos por iteración. De tal modo que nos da bastante tiempo para ver con comodidad los resultados, pero esto es útil cuando los cálculos son pocos.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Mi ejemplo de código entonces es:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
figure(1);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
for i=1:1000&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
T(i)=cos(i);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
plot(T);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
drawnow;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
pause(0.3)&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
end&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;El factor comet&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
El comando &lt;b&gt;&lt;a href=&quot;http://www.mathworks.com/help/techdoc/ref/comet.html&quot;&gt;comet&lt;/a&gt;&lt;/b&gt; es otra opción para darle movimiento a la construcción de nuestras gráficas. Sin embargo, para pocos puntos su ejecución es demasiado rápida para apreciarse. Por lo cual se requieren muchos puntos para poder apreciar la construcción. Una alternativa es disminuir el paso entre punto y punto o aumentar el intervalo del vector a graficar.  Lamentablemente, este comando no tiene una opción para controlar la velocidad, y aunque se puede alterar el código original para cambiar la velocidad, no es muy recomendable si estas iniciando el arte de hacer código para Matlab. &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Pero si sientes que tu experiencia es suficiente para hacerlo, pues te recomiendo ir a los foros del mismo Matlab Central donde te puedes dar una idea de cómo hacer tal alteración: &lt;a href=&quot;http://www.mathworks.com/matlabcentral/newsreader/view_thread/20614&quot;&gt;foro1&lt;/a&gt;, &lt;a href=&quot;http://www.mathworks.com/matlabcentral/answers/3739-comet-how-can-slow-down-the-animation&quot;&gt;foro2&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
El siguiente video te muestra el código y los resultados que obtengo.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;iframe allowfullscreen=&quot;allowfullscreen&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;http://www.youtube.com/embed/bkeq7uu_Yug&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Preguntas para pensar&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1)&lt;/b&gt; Sin que se cree un video en que casos particulares es más útil esta opción que la de crear un video en Matlab. Revisa nuestra entrada anterior &amp;nbsp;sobre la &amp;nbsp;&lt;a href=&quot;http://5minutosdematlab.blogspot.mx/2012/03/como-hacer-la-animacion-de-una-senoidal.html&quot;&gt;creación de animaciones&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Ejercicios&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1)&lt;/b&gt; &amp;nbsp;Realiza una rutina donde se pueda visualizar al mismo tiempo varias gráfica en un una sola ventana, puedes usar el comando &lt;b&gt;&lt;a href=&quot;http://www.mathworks.com/help/techdoc/ref/subplot.html&quot;&gt;subplot&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;2) &lt;/b&gt;Aplica esta solución para ver la dinámica una gráfica de tres variables (X,Y,Z) que cambia con el tiempo.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/8774892312342487126/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/08/dibujando-graficas-como-si-fueran.html#comment-form' title='7 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/8774892312342487126'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/8774892312342487126'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/08/dibujando-graficas-como-si-fueran.html' title='Dibujando gráficas como si fueran animaciones en Matlab '/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4tIdiqUhPsMZ5kwIlnuPsJZxnz3b-TDcAgTyXvhtVzSrN45k4vq6gIs8qtKZPST4ZZdr6-RXImYNeyrFSEVlHW1pRWgeHRAh9PkcBslRQY_TqqORmwgqaFKmq8uH8brKC08vIThUJYeo/s72-c/dibujo_tiempo_real_animacion_matlab.jpg" height="72" width="72"/><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-7900431699036062145</id><published>2012-08-27T09:41:00.002-07:00</published><updated>2012-08-27T09:42:16.237-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Codigos"/><category scheme="http://www.blogger.com/atom/ns#" term="Temas avanzados"/><title type='text'>Uso de operaciones vectoriales en lugar de ciclos for para aumentar el desempeño de Matlab</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4eg3JITM5v5K5j6yV8_gucfbj3lYzoknaxLw5DLdpwier6SZrMQMD9zmUmDNO-oFv2BA1PhYg4MVHlqT3sLHbt-4bAY7YYYtuus8pETSrHRXROfofdPLos59-p9d9FAkGrvQKgUqWdDo/s1600/aumento_velocidad_matlab.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4eg3JITM5v5K5j6yV8_gucfbj3lYzoknaxLw5DLdpwier6SZrMQMD9zmUmDNO-oFv2BA1PhYg4MVHlqT3sLHbt-4bAY7YYYtuus8pETSrHRXROfofdPLos59-p9d9FAkGrvQKgUqWdDo/s1600/aumento_velocidad_matlab.jpg&quot; height=&quot;200&quot; width=&quot;128&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Consideremos el siguiente ciclo, reescrito directamente de C o Fortran&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
dx = pi/30;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
nx = 1+ 2*pi/dx;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
for i = 1:nx&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;x(i) = (i-1) * dx;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;y(i) = sin(3*x(i));&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
end&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Todas las declaraciones anteriores son validas en Matlab, pero son ineficientes en el proceso de crear tanto a &lt;i&gt;x&lt;/i&gt; como a &lt;i&gt;y&lt;/i&gt;.  Recordemos, Matlab localiza memoria para las variables cada vez que se les añade un nuevo miembro. Como ya lo comentamos en anteriormente en &lt;a href=&quot;http://5minutosdematlab.blogspot.mx/2012/08/uso-de-pre-asignacion-de-memoria-en.html&quot;&gt;una entrada sobre reasignación de memoria&lt;/a&gt; RAM.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Entonces el mejor modo de crear los mismos dos vectores x y y es mediante los siguientes comandos:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
x = 0: pi/30:2*pi;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
y = sin(3*x);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
La primera declaración crea al vector x; con 61 elementos que son almacenados en zonas continuas del RAM. La segunda declaración crea una nueva matriz, y, con el mismo número de elementos que x.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Matlab está diseñado para desarrollar eficientemente operaciones de matrices y vectores. Para tomar la ventaja máxima del hardware de la computadora; por tanto debemos utilizar operaciones vectoriales lo más que podamos.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Un ejemplo más sofisticado&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
A pesar que Matlab ajusta automáticamente el tamaño de una matriz (o vector) es mucho mejor predesignar la memoria de la matriz. La preasignación garantiza que los elementos de la matriz se almacenaran en zonas continuas de la memoria RAM y que sólo se realizara una vez este proceso.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Consideremos este ejemplo (que admito es artificial, pero&amp;nbsp;didáctico) para crear dos vectores x y y:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
dx = pi/30;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
nx = 1 + 2*pi/dx;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
nx2 = nx/2;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
for i = 1:nx2&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp; &amp;nbsp; x(i) = (i-1)*dx;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp; &amp;nbsp; y(i) = sin(3*x(i));&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
end&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
for i = round(nx2):nx&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;x(i) = (i-1)*dx;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;y(i) = sin(5*x(i));&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
end&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Aquí, conocemos desde el principio el tamaño de los vectores &lt;i&gt;x&lt;/i&gt; y &lt;i&gt;y&lt;/i&gt;. Así que reasignaremos la memoria creando un vector antes de que sus elementos sean individualmente asignados. Por lo común se utilizan las &lt;b&gt;&lt;a href=&quot;http://www.mathworks.com/help/techdoc/ref/ones.html&quot;&gt;funciones ones &lt;/a&gt;&lt;/b&gt;y &lt;a href=&quot;http://www.mathworks.com/help/techdoc/ref/zeros.html&quot;&gt;zeros&lt;/a&gt; para la reasignación de memoria; por ejemplo, de este modo:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
dx = pi/30;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
nx = 1 + 2*pi/dx;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
nx2 = nx/2;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
x = zeros(1,nx);      % pre-allocate row-vectors, x&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
y = zeros(1,nx);      % and y&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
for i = 1:nx2&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
x(i) = (i-1)*dx;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
y(i) = sin(3*x(i));&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
end&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
for i = round(nx2):nx&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
x(i) = (i-1)*dx;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
y(i) = sin(5*x(i));&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
end&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Sin embargo, las declaraciones x(i) y y(i) no han tomado ventaja de la vectorización, aunque los elementos de x y y han sido almacenados continuamente en la RAM.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Así que mejoraremos estas declaraciones mediante un poco de vectorización. Por ejemplo, escribiendo:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
x = 0:pi/30:2*pi;     % vectorized calculation of x&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
nx = length(x);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
nx2 = nx/2;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
y = x;                % pre-allocate memory for y&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
for i = 1:nx2&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;y(i) = sin(3*x(i));&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
end&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
for i = round(nx2):nx&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp; &amp;nbsp; y(i) = sin(5*x(i));&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
end&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Finalmente, podemos observar que los cálculos de y puede también ser vectorizados. Por ejemplo, de este modo:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
x = 0:pi/30:2*pi;     % vectorized calculation of x&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
nx = length(x);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
nx2 = nx/2;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
y = x;                             % pre-allocate memory for y&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
y(1:nx2) = sin(3*x(1:nx2));        % compute first part of y&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
y(round(nx2):nx) = sin(5*x(round(nx2):nx));  % and the second part&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
En mi computadora, resulta que el aumento de velocidad fue de aprox. 1.2 veces. Es decir, utilizar los cálculos basados en vectores fue notoria la mejora. Sin embargo, en este ejemplo son pocos los elementos de los vectores. Mientras más grande es la matriz o vector, más significativo será utilizar vectorización en lugar de una reconstrucción de la matriz por medio del ciclo for.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Por cierto, para medir el tiempo de estos ejemplos, los he escrito como rutinas (scripts que los nombre  ejemplo_vector.m) y utilice los siguientes comandos para medir el tiempo. &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
clear; tic; ejemplo_vector; disp( [&#39;se tardo &#39; num2str(toc) &#39;s.&#39;] );&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Y la salida de este ejemplo es la siguiente imagen:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaf0sOW6-_MEiSWgt0-kbAg-vxh-tt7vktzTDP64Ssbsp4_NCOtKIHKL2pF6s-7uOwH1aWbegg_SBoITmlz56uZ0zlHeIEzmhdHGPWXt47D1HYiU9KLX6PQaqREKkaO7sR_kzeMgvoAE4/s1600/salida_matlab_senos.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaf0sOW6-_MEiSWgt0-kbAg-vxh-tt7vktzTDP64Ssbsp4_NCOtKIHKL2pF6s-7uOwH1aWbegg_SBoITmlz56uZ0zlHeIEzmhdHGPWXt47D1HYiU9KLX6PQaqREKkaO7sR_kzeMgvoAE4/s1600/salida_matlab_senos.png&quot; height=&quot;273&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/7900431699036062145/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/08/uso-de-operaciones-vectoriales-en-lugar.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/7900431699036062145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/7900431699036062145'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/08/uso-de-operaciones-vectoriales-en-lugar.html' title='Uso de operaciones vectoriales en lugar de ciclos for para aumentar el desempeño de Matlab'/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4eg3JITM5v5K5j6yV8_gucfbj3lYzoknaxLw5DLdpwier6SZrMQMD9zmUmDNO-oFv2BA1PhYg4MVHlqT3sLHbt-4bAY7YYYtuus8pETSrHRXROfofdPLos59-p9d9FAkGrvQKgUqWdDo/s72-c/aumento_velocidad_matlab.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-4116196266964414604</id><published>2012-08-26T19:16:00.001-07:00</published><updated>2012-08-27T09:59:44.537-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Codigos"/><category scheme="http://www.blogger.com/atom/ns#" term="material extra"/><category scheme="http://www.blogger.com/atom/ns#" term="Temas avanzados"/><title type='text'>Uso de pre-asignación de memoria en Matlab para aumentar la velocidad de cálculos</title><content type='html'>&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://www.cwrl.utexas.edu/~bump/603A11/w/Vulture/website/2ndsemester/fh1_files/image004.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;175&quot; src=&quot;http://www.cwrl.utexas.edu/~bump/603A11/w/Vulture/website/2ndsemester/fh1_files/image004.jpg&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://www.cwrl.utexas.edu/~bump/603A11/w/Vulture/website/2ndsemester/fh1.htm&quot;&gt;Fun home 1&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Como en cualquier otra actividad, programar requiere seguir reglas para ser efectivo. Del mismo modo en que deberíamos limpiar nuestro cuarto de vez en cuando; debemos economizar la memoria de la computadora.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Por ello, en esta entrada, platicaré de las bases de la preasignacion de memoria (&lt;i&gt;&lt;a href=&quot;http://www.mathworks.com/help/techdoc/matlab_prog/f8-784135.html#f8-793781&quot;&gt;memory preallocation&lt;/a&gt;&lt;/i&gt;) en Matlab. La preasignación de memoria es una práctica excelente de programación que SIEMPRE debemos seguir.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;¿De qué trata la preasignación de memoria en Matlab?&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
A diferencia de los otros lenguajes de programación, como C; Matlab “cuida” de la asignación de memoria automáticamente.  Así cuando ejecutas un programa, Matlab reserva espacios de memoria para los datos de todas las variables que se utilizan. Y esto se basa en información local, de un modo similar  como en el caso de los tipos de datos o el espacio necesario para todos los elementos. &amp;nbsp;Veamos un ejemplo con código Matlab:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
X = 1:100;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Y = cos(X);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
En la línea 1, Matlab identifica que X es un vector compuesto de 100 elementos de formato doble. Entonces reserva la memoria necesaria para cuando se emplee.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
En la línea 2, Y es del mismo tamaño que X, de modo que Matlab reserva memoria antes de llenar el espacio con la información de la función cos(X).&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Una consecuencia de este mecanismo es que CADA VEZ que se le pide a Matlab almacenar un nuevo conjunto de datos, Matlab realiza el proceso de asignar algo de memoria. Por ejemplo:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
X = 1:100;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
X(101) = 1;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
En este ejemplo,  X  está compuesto inicialmente de 100 elementos; luego cuando se le ordena a Matlab que llene el elemento 101, implícitamente se le pide a Matlab que reasigne algo de memoria para que se pueda incluir el nuevo elemento de X.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;¿Por qué tanto alboroto con la preasignación de memoria?&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Para todos los datos en una matriz, Matlab requiere un proceso de memoria continua. Como resultado, si el espacio de memoria para el espacio 101 es solicitado; entonces Matlab copia todos los valores originales de X y los coloca en un nuevo sitio donde hay espacio para hasta los 101 elementos.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Veamos un ejemplo más extremo, si X esta hecho 100 mil elementos en lugar de 100, el tamaño de memoria para X es grande y estos grandes espacios de memoria no son tan fáciles de localizar.  Es como querer estacionar un autobús turístico en el centro de la ciudad… toma bastante tiempo.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Es especialmente en los ciclos for cuando este proceso de asignación de memoria es notorio. Por ejemplo en esta rutina (script) al que llame ejemplo_memoria0: &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
for i=1: 100000&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Y(i)=cos(i);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
end&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
En este caso, a cada paso en el &lt;a href=&quot;http://www.mathworks.com/help/techdoc/ref/for.html&quot;&gt;&lt;b&gt;&lt;span id=&quot;goog_2052587606&quot;&gt;&lt;/span&gt;ciclo for&lt;/b&gt;&lt;span id=&quot;goog_2052587607&quot;&gt;&lt;/span&gt;&lt;/a&gt;, se le pide a Matlab que añada un elemento a la matriz Y. De hecho, se le pide a Matlab que engrose a Y en memoria a cada paso.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Al principio del proceso, es fácil y rápido; pues Y es pequeño.  Pero a medida que progresa el ciclo, Y se hace cada vez más grande, de modo que Matlab debe encontrar espacios de memoria mucho más grandes.  Por lo que se vuelve una pesadilla de asignare&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;La solución es simple: preasignación de memoria&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
La idea se basa en que tú sabes de antemano cual será el tamaño del vector, por ello se lo debes comunicar a la computadora antes de que entre en el ciclo for. Por ejemplo, la&amp;nbsp;mayoría&amp;nbsp;de las personas utilizan funciones como &lt;a href=&quot;http://www.mathworks.com/help/techdoc/ref/ones.html&quot;&gt;ones&lt;/a&gt; o &lt;a href=&quot;http://www.mathworks.com/help/techdoc/ref/zeros.html&quot;&gt;zeros&lt;/a&gt; de este modo:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
Y = zeros(100000,1);&lt;/div&gt;
&lt;div&gt;
for i= 1:100000&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;Y(i) = cos(i);&lt;/div&gt;
&lt;div&gt;
end&lt;/div&gt;
&lt;div&gt;
&lt;br class=&quot;Apple-interchange-newline&quot; /&gt;&lt;/div&gt;
&lt;div&gt;
En mi computadora viejita y sobre-explotada, la primera versión tarda: 21.6511 s; y utilizando la pre-asignación&amp;nbsp;de memoria tarda en ejecutarse: 0.009333 s. Es decir,&amp;nbsp;estos cambios significaron que: ¡¡~688 VECES AUMENTÓ LA VELOCIDAD DEL CÁLCULO!!&lt;/div&gt;
&lt;div&gt;
&lt;br class=&quot;Apple-interchange-newline&quot; /&gt;&lt;/div&gt;
&lt;br /&gt;
Ahora, se puede aumentar la velocidad un poco más.  En lugar de gastar el tiempo llenado con ceros una matriz, se le puede pedir a Matlab que llene solamente el último elemento de un vector.  Por ejemplo:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Y (100000) =0;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
for i= 1:100000&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Y(i) = cos(i);&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
end&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
En este último caso, la rutina tardo 0.009074 s.  Este ahorro de tiempo es especialmente significativo cuando se construyen diversas matrices de gran tamaño.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Preguntas para pensar:&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1)&lt;/b&gt; ¿Cuáles otras prácticas de programación se deben emplear para aumentar la eficiencia de nuestros programas?&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Ejercicios&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;1)&lt;/b&gt; En la línea de comandos de Matlab, yo utilicé los siguientes comandos para medir el tiempo de ejecución de mi rutina:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
clear, tic; ejemplo_memoria0; disp( [&#39;se tardo &#39; num2str(toc) &#39;s.&#39;] );&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;a)&lt;/b&gt; ¿Qué hace los comandos tic y toc?&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;b)&lt;/b&gt; En este caso, ¿Por qué es necesario transformar un número en cadena de caracteres?&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;c) &lt;/b&gt;Crea una tabla con los tres ejemplos mostrados en esta entrada donde se muestre la diferencia de velocidades en los procesos de cálculo,&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/4116196266964414604/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/08/uso-de-pre-asignacion-de-memoria-en.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/4116196266964414604'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/4116196266964414604'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/08/uso-de-pre-asignacion-de-memoria-en.html' title='Uso de pre-asignación de memoria en Matlab para aumentar la velocidad de cálculos'/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-6038449046074036678</id><published>2012-08-22T09:31:00.002-07:00</published><updated>2012-08-22T09:31:56.217-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Actividades"/><category scheme="http://www.blogger.com/atom/ns#" term="Curso 2012"/><title type='text'>Próximos temas  de graficación en Matlab, curso 2012</title><content type='html'>&lt;br /&gt;
&lt;span style=&quot;text-align: justify;&quot;&gt;Estos son los próximos temas que veremos en la clase presencial. Empezando por el comando mas sencillo de este tema: &lt;b&gt;plot&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Les pido que empiecen a hacer gráficas simples y si pueden los ejercicios de la sig. lista de entradas.&lt;/div&gt;
&lt;ol&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://5minutosdematlab.blogspot.mx/2012/03/como-hacer-graficas-polares-0009.html&quot;&gt;Cómo hacer graficas polares (0009)&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://5minutosdematlab.blogspot.mx/2012/05/como-poner-una-linea-de-tendencia-en.html&quot;&gt;Cómo poner una linea de tendencia en Matlab (0014)&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://5minutosdematlab.blogspot.mx/2012/03/como-hacer-graficas-de-funciones-zxy.html&quot;&gt;Cómo hacer gráficas de funciones z(x,y) (0011)&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://5minutosdematlab.blogspot.mx/2012/03/como-hacer-graficas-parametricas-en-el_22.html&quot;&gt;Cómo hacer gráficas parámetricas en el espacio con Matlab (0010)&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://5minutosdematlab.blogspot.mx/2012/03/como-variar-los-colores-en-una-grafica.html&quot;&gt;Cómo variar los colores en una gráfica 3D (0013)&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://5minutosdematlab.blogspot.mx/2012/03/como-hacer-la-animacion-de-una-senoidal.html&quot;&gt;Cómo hacer la animación de una senoidal en función del tiempo (0012)&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br class=&quot;Apple-interchange-newline&quot; /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/6038449046074036678/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/08/proximos-temas-de-graficacion-en-matlab.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/6038449046074036678'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/6038449046074036678'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/08/proximos-temas-de-graficacion-en-matlab.html' title='Próximos temas  de graficación en Matlab, curso 2012'/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-4886133519540440568</id><published>2012-08-22T09:20:00.000-07:00</published><updated>2012-08-22T09:21:03.508-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Actividades"/><category scheme="http://www.blogger.com/atom/ns#" term="Codigos"/><category scheme="http://www.blogger.com/atom/ns#" term="Curso 2012"/><category scheme="http://www.blogger.com/atom/ns#" term="Respuestas"/><title type='text'>Funciones y comparación de cadenas de caracteres</title><content type='html'>Este es un código que muestra como se pueden comparar cadenas caracteres. Es en respuesta a la duda (que se comento en clase) de un &lt;a href=&quot;http://5minutosdematlab.blogspot.mx/2012/08/como-hacer-funciones-escalares-y.html&quot;&gt;ejercicio para la&amp;nbsp;creación&amp;nbsp;de funciones&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Por favor, prueben la función e interpreten el proceso de trabajo, usen los comando &lt;b&gt;tic toc &lt;/b&gt;de Matlab&amp;nbsp;para ver cuanto tiempo tarda en ejecutarse, y si pueden modifiquen para disminuir este tiempo.&lt;br /&gt;
&lt;br /&gt;
Y si tienen dudas, pueden dejar un comentario en esta entrada.&lt;br /&gt;
&lt;br /&gt;
%% Esta fucion permite calcular entre la funcion seno y coseno.&lt;br /&gt;
&lt;br /&gt;
% Acepta escalares y matrices&lt;br /&gt;
% Si se escribe mal la palabra se termina el programa&lt;br /&gt;
&lt;br /&gt;
function y = trigos(cadena)&lt;br /&gt;
display(&#39;¿Qué función deseas usar?&#39;); % estos son mensajes para orientar al usuario&lt;br /&gt;
display(&#39; &#39;);&lt;br /&gt;
display(&#39;Escribe la palabra &amp;lt;&lt;coseno&gt;&amp;gt; si quieres usar la función coseno.&#39;);&lt;/coseno&gt;&lt;br /&gt;
display(&#39;o escribe la palabra &amp;lt;&lt;seno&gt;&amp;gt; si quieres usar la función seno&#39;);&lt;/seno&gt;&lt;br /&gt;
palabra = input(&#39;Cualquier otra palabra te saca de esta funcion \n&#39;,&#39;s&#39;); % aqui se almacena la cadena&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;if strcmp(palabra, &#39;coseno&#39;) == 1 ; % strcmp compara las cadenas, si son iguales da un valor de 1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;y = cos(cadena);&lt;br /&gt;
&amp;nbsp;elseif strcmp(palabra, &#39;seno&#39;) == 1 ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;y = sin(cadena);&lt;br /&gt;
&amp;nbsp;else strcmp(palabra, &#39;coseno&#39;) || strcmp(palabra, &#39;seno&#39;) == 0 ; % esta parte permite versatilidad en las salidas nulas&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;display(&#39;la función no esta declarada. Adios :)&#39;); % se le orienta al usuario que sucede en el programa&lt;br /&gt;
&amp;nbsp;end&lt;br /&gt;
&lt;br /&gt;
% fin de la funcion&lt;br /&gt;
%%%</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/4886133519540440568/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/08/funciones-y-comparacion-de-cadenas-de.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/4886133519540440568'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/4886133519540440568'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/08/funciones-y-comparacion-de-cadenas-de.html' title='Funciones y comparación de cadenas de caracteres'/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5635612627780359488.post-7544158806411341627</id><published>2012-08-20T08:21:00.000-07:00</published><updated>2012-08-20T08:21:17.478-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Temas básicos"/><category scheme="http://www.blogger.com/atom/ns#" term="Videos"/><title type='text'>Cómo hacer funciones escalares y vectoriales en Matlab (0017)</title><content type='html'>&lt;b&gt;&lt;/b&gt;&lt;iframe allowfullscreen=&quot;allowfullscreen&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;http://www.youtube.com/embed/xiMT7VPi0LI&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Resumen&lt;/b&gt;&lt;br /&gt;
Mostramos los fundamentos de cómo hacer fuciones en Matlab, las cuales pueden trabajar con escalares, vectores y matrices.&lt;br /&gt;
&lt;br /&gt;
Empleamos la palabra reservada de Matlab &lt;b&gt;function&lt;/b&gt; para crear una función&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Preguntas para pensar&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt; &lt;b&gt;1) &lt;/b&gt;En que casos es recomendable utilizar funciones en Matlab&lt;br /&gt;
&lt;b&gt;2)&lt;/b&gt;&amp;nbsp;¿Se&amp;nbsp;debería&amp;nbsp;escribir primero un guion antes de hacer una función en Matlab?&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Ejercicios&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;1)&lt;/span&gt;&lt;/b&gt; Escribe un archivo .m de la función, &lt;b&gt;fun_es(x)&lt;/b&gt;, que calcule la siguiente función: &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;a href=&quot;http://www.codecogs.com/eqnedit.php?latex=\dpi{150}%20y%20=%200.5%20e^{x/3}-%20x^2\sin(x)&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://latex.codecogs.com/gif.latex?\dpi{150} y = 0.5 e^{x/3}- x^2\sin(x)&quot; title=&quot;\dpi{150} y = 0.5 e^{x/3}- x^2\sin(x)&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
El argumento debe aceptar  tanto un escalar como un vector. Pruebe su función tecleando en la ventana de comandos de Matlab: fun_es(3) y fun_es([1 2 3])&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;2&lt;/b&gt;)&lt;/span&gt; Repita la tarea del ejercicio 1) para la función &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;a href=&quot;http://www.codecogs.com/eqnedit.php?latex=\dpi{150}%20y%20=\sin%20(x)%20\log(1@plus;x)%20%E2%80%93x^2,%20x%3E0&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://latex.codecogs.com/gif.latex?\dpi{150} y =\sin (x) \log(1+x) –x^2, x&amp;gt;0&quot; title=&quot;\dpi{150} y =\sin (x) \log(1+x) –x^2, x&amp;gt;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Denote la función por &lt;b&gt;fun_lg(x)&lt;/b&gt;.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;3)&lt;/span&gt;&lt;/b&gt; Se supone que el lector ya creó las funciones &lt;b&gt;fun_es&lt;/b&gt; y &lt;b&gt;fun_lg&lt;/b&gt; de los problemas 1) y 2). Ahora, cree una función &lt;b&gt;f_es(x)&lt;/b&gt; que: &lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;•&lt;/b&gt; pregunte el nombre de la función que se desea evaluar,&lt;/div&gt;
&lt;b style=&quot;text-align: justify;&quot;&gt;•&lt;/b&gt;&lt;span style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;permita al usuario teclear el nombre de la función,&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;•&lt;/b&gt;&amp;nbsp;evalúe la función con el comando de Matlab &lt;b&gt;feval&lt;/b&gt; y devuelva los valores funcionales y &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;•&lt;/b&gt; se detenga  si la fucnion indicada por el usuario no es fun_es ni fun_lg.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Pruebe su f_es calculando fun_es(3) y fun_lg(3).&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://5minutosdematlab.blogspot.com/feeds/7544158806411341627/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/08/como-hacer-funciones-escalares-y.html#comment-form' title='4 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/7544158806411341627'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5635612627780359488/posts/default/7544158806411341627'/><link rel='alternate' type='text/html' href='http://5minutosdematlab.blogspot.com/2012/08/como-hacer-funciones-escalares-y.html' title='Cómo hacer funciones escalares y vectoriales en Matlab (0017)'/><author><name>vicentz</name><uri>http://www.blogger.com/profile/06029515787986373336</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/xiMT7VPi0LI/default.jpg" height="72" width="72"/><thr:total>4</thr:total></entry></feed>