|
Laboratori d'Automatització i Robòtica, Universitat de Lleida
|
|
MatLab shared functions
24/07/2024 - getfigure70.m (version 7.0)

Sharing our
Matlab tool
getfigure70.m (version 7.0) that simplifies the copy of axis, lines, and images
from another figure.
Click on the image to see the the menus and submenus of the tool.
The first call to this function adds a new
Getfigure menu (in the current figure) and the second call deletes the
Getfigure menu (in the current figure):
>> getfigure70
12/07/2024 - 'roseus' colormap for Matlab

Sharing our
Matlab function:
roseus.m (also available at
FileExchange)
c = roseus(M) returns an M-by-3 matrix containing the 'roseus' colormap.
roseus, by itself, uses the length of the current figure's colormap.
It works like the other colormaps: hot, hsv, parula, gray,...
The 'roseus' colormap is used in audacity for improved spectrum visualization.
Adjust the color limits of the spectrum image to mimic the audacity spectrum.
Usage examples:
>>c = roseus(15); % returns a 15x3 'roseus' colormap
>>c = roseus; % returns a Mx3 colormap, M is the length of the current figure's colormap or 64 (shown in the figure)
>>colormap(roseus); % sets the 'roseus' colormap on the current figure
12/07/2024 - Display a Matlab matrix as text
Sharing our
Matlab function:
matrix2m.m (also available at
FileExchange)
matrix2m(A, digits) returns the matrix A as a displayed text.
Designed to copy/add a raw matrix into an m file.
The matrix A can have one, two or three dimensions
Usage example:
>>A = rand(1,4);
>>matrix2m(A); % returns the text description of A, as follows
Text to be copied into your m file:
A = [0.2583 0.4094 0.5951 0.2626];
19/06/2024 - Featuring: MediaPipe demo
MediaPipe is a machine learning (ML) solution. Some
JavaScript ready-to-use web examples:
Holistic detection: a web example that uses the camera to detect the face, body, hands,...
Face Mesh detection: a web example that uses the camera to detect the face and fit a mesh, like the figure on the left
More ready-to-use examples: https://codepen.io/mediapipe
07/06/2024 - getfigure68.m (version 6.8)

Sharing our
Matlab tool
getfigure68.m (version 6.8) that simplifies the copy of axis, lines, and images
from another figure.
Click on the image to see the the menus and submenus of the tool.
The first call to this function adds a new
Getfigure menu (in the current figure) and the second call deletes the
Getfigure menu (in the current figure):
>> getfigure68
15/04/2024 - getfigure65.m (version 6.5)
Sharing our
Matlab function
getfigure65.m (version 6.5) that simplifies the copy of axis, lines, and images
from another figure.
The first call to this function adds a new
Getfigure menu (in the current figure) and the second call deletes the
Getfigure menu:
>> getfigure65
21/12/2023 - New version (5.1) of the
SLAMICP-Library
This
new version 5.1 of the
SLAMICP-Library optimizes the "point_to_plane"
ICP matching by avoiding to compute the normals of the reference map in each iteration.
There is also a specific function to compute the normals (red arrows) of a point cloud (blue points).
17/10/2023 - Copy a Matlab matrix in Word

Sharing our
Matlab functions:
matrix2WordTable.m and
matrix2WordEq.m
>> matrix2WordTable(M);
This function copies the matlab matrix M into a
Word document (through the clipboard):
1) Create an space for the table in word. 2) Call this function. 3) Click over Word. 4) Wait until the whole matrix has been copied (do not change the focus from Word).
Function also avialable at
Fileexchange.
>> matrix2WordEq(M);
This function copies the matlab matrix M into a
Word equation (through the clipboard):
1) Create an empty equation in word. 2) Call this function. 3) Click over the Word equation. 4) Wait until the whole matrix has been copied (do not change the focus from Word).
Function also avialable at
Fileexchange.
05/07/2023 - dijkstra.m (version 1.0)

Sharing our
Matlab function
dijkstra.m
( also available at
FileExchange )
A single-function implementation of Dijkstra's algorithm for shorter path finding in a directed matrix-graph
Didactic reference at:
Dijkstra's algorithm explained, https://youtu.be/bZkzH5x0SKU
% Matrix-Graph example G
% G(a,b)=z defines a directional link (with a weight z) from the node a to b
G = [0 1 0 0 0 0 0;
0 0 1 0 0 10 0;
2 0 0 1 0 0 0;
0 0 2 0 1 0 0;
0 0 0 2 0 1 0;
0 0 0 0 2 0 1;
0 0 0 0 0 2 0];
initialNode = 1;
finalNode = 7;
[best_route,cost,M] = dijkstra(G,initialNode,finalNode)
best_route =
1 2 3 4 5 6 7
cost =
6
% Interpretation of the columns of the Dijkstra matrix M
% Node number | best previous node | cumulated path lenght or cost | node visited
M =
1 0 0 1
2 1 1 1
3 2 2 1
4 3 3 1
5 4 4 1
6 5 5 1
7 6 6 1
• Related research paper:
Path Planning of a Mobile Delivery Robot Operating in a Multi-Story Building Based on a Predefined Navigation Tree
26/01/2023 - Featuring: Matlab based ICP implementations
simpleICP: matlab function Iterative Closest Point Matching (also available at
FileExchange)
globalICP: A multi-scan ICP implementation for Matlab
11/11/2022 - Featuring: ReadSpeaker
Text-to-Speech demo with many languages and voices available
Ready to be embedded in many practical applications
09/04/2022 - Feturing: Ellipse Detection Using 1D Hough Transform
Available at Matlab Fileexchange:
ellipseDetection(img, params), by Martin Simonovsky
Fits an ellipse by examining all possible major axes (all pairs of points) and getting the minor axis using Hough transform
Selected as
File Exchange Pick of the Week
18/03/2022 - Cámara RGB-D Ceative BlasterX Senz3D: consumo de corriente conectada a un puerto USB 3.0
Cable USB conectado pero sin ninguna aplicación accediendo a la cámara: 80 mA
Con una conexión activa pero
sin utilizar la cámara (sin pedirle imágenes): 45 mA
Utilizada (solo) como cámara
RGB (como una webcam normal): 240 mA
Utilizada plenamente como cámara
RGB-D: 450 mA
Utilizando (solo) el stream D: 360 mA
Utilizando (solo) el stream RGB: 240 mA
Utilizando (solo) el stream IR: 300 mA
Utilizando los streams D y el IR: 360 mA
Utilizando los streams RGB y el IR: 380 mA
Utilizando los streams RGB y el D: 450 mA
En W10 se necesita el Intel® RealSense 2.0 (no funciona con la versión 1.0).
La cámara no funciona en un USB 2.0.
18/03/2022 - Cámara RGB-D Ceative 3D Senz: consumo de corriente conectada a un puerto USB 2.0
Cable USB conectado pero sin ninguna aplicación accediendo a la cámara: 120 mA
Con una conexión activa pero
sin utilizar la cámara (sin pedirle imágenes): 120 mA
Utilizada (solo) como cámara
RGB (como una webcam normal): 140 mA
Utilizada plenamente como cámara
RGB-D: 400 mA
Utilizando (solo) el stream D: 400 mA
Utilizando (solo) el stream RGB: 140 mA
Utilizando los streams RGB y el D: 400 mA
En W10 se necesita el Intel® Perceptual Computing™ 2013 (no funciona con la versión Intel® RealSense™ 2.0)
15/12/2021 - WITmotion 16 channel servo driver
WITMotion 16 channel servo driver control
% Control de WIT motion servo controller 16 chanels mediante MatLab
% Comunicación mediante USB-serial externo (con el interno no funciona)
% Tramas de datos
% | 0xFF | 0x(XX) | 0x(XX) | 0x(XX) | 0x(XX) |
% |Byte |Byte | # de | Data 2 | Data 1 |
% |de |de | servo | | |
% |Confirmación |acción | [0-15] | | |
% |(Siempre |0x01 velocidad | | | |
% | 0xFF) |0x02 posición | | | |
% | |0x09 en grupo | | | |
% | |0x0b emergencia | | | |
% Conectar el puerto 'COMX' con MatLab para acceso serie (RS232)
s = serial('COM3'); % Por defecto: 9.600bps, 8bits, sin paridad, 1 stop
% Abrir la comunicación serie con el puerto
fopen(s);
% Parámetros de control
% Número de serovo a controlar, de 0 a 15
servo = 2;
% Velocidad de giro en grados por segundo, de 9º/s a 180º/s
velocidad = 90;
% Debe convertirse en un valor entre 1 (9º/s) y 20 (180º/s)
velocidad = round((velocidad*10)/90);
% Posición en grados, de 0º a 180º
posicion = 90;
% Debe convertirse a un valor de control entre 500 y 2500
% realmente se envía el ancho del pulso de control en microsegundos
posicion = round(500+(111*(posicion/10)));
% Los datos se deben enviar en dos bytes
% Ejemplo: para enviar el valor 2498 que equivale a 0x09C2
% se sebe enviar primero 0xC2 y luego 0x09
Data2 = posicion - 256*fix(posicion/256);
Data1 = fix(posicion/256);
% Enviar velocidad de movimiento
fwrite(s,[hex2dec('ff') hex2dec('01') servo velocidad hex2dec('00')]);
% Enviar la posición destino
fwrite(s,[hex2dec('ff') hex2dec('02') servo Data2 Data1]);
pause(2);
% Finalizar la comunicación
fclose(s); % Cerrar la comunicación serie (se puede volver a abrir)
delete(s); % Desconectar definitivamente el puerto 'COMX' de MatLab
24/08/2021 - Recordatorio: apagar el PC-W10 de forma temporizada
Acceder a la consola de comandos mediante una de estas alternativas:
- Teclear cmd en la lupa de búsqueda para acceder a la consola de comandos o 'Símbolo del Sistema'
- Pulsar simultáneamente las teclas [Windows] y [R] y en la ventana teclear cmd
En la consola de comandos teclear
shutdown para ver todas las opciones que ofrece el programa de autoapagado de W10
- Para apagar el equipo inmediatamente teclear: shutdown /s
- Para reiniciar el equipo inmediatamente teclear: shutdown /r
- Para programar un apagado del equipo para dentro de 5 minutos (5x60 = 300 segundos) teclear: shutdown /s /t 300
- Para programar un apagado del equipo para dentro de 60 minutos (60x60 = 3600 segundos) teclear: shutdown /s /t 3600
- Para programar un apagado del equipo para dentro de 3 horas (3x60x60 = 10800 segundos) teclear: shutdown /s /t 10800
- Para programar un apagado del equipo para dentro de 4 horas (4x60x60 = 14400 segundos) teclear: shutdown /s /t 14400
- Para programar un apagado del equipo para dentro de 5 horas (5x60x60 = 18000 segundos) teclear: shutdown /s /t 18000
- Para programar un apagado del equipo para dentro de 6 horas (6x60x60 = 21600 segundos) teclear: shutdown /s /t 21600
- Para programar un reinicio del equipo para dentro de 60 minutos (60x60 = 3600 segundos) teclear: shutdown /r /t 3600
- Para programar un reinicio del equipo para dentro de 6 horas (6x60x60 = 21600 segundos) teclear: shutdown /r /t 21600
- Para anular la acción programada teclear: shutdown /a
Otra aplicación muy interesante es copiar archivos de una carpeta a otra a la máxima velocidad posible y apagar automáticamente el ordenador al terminar
- Para copiar archivos teclear en la línea de comandos: robocopy c:/fotos g:/fotos_2021 /E & shutdown /s
- Para mover archivos teclear en la línea de comandos: robocopy c:/fotos g:/fotos_2021 /MOVE & shutdown /s
Ver todos los comandos disponibles en el '
Símbolo del Sistema':
- Ejemplo, ejecutar el bloc de notas en la CPU 0: start /affinity 1 notepad.exe
- Ejemplo, establecer un retardo de 10 segundos en un archivo batch: timeout 10 /nobreak
- Ejemplo, establecer un retardo de 5 segundos sin información en pantalla en un archivo batch: timeout 5 > null
- Ejemplo, establecer una pausa de 6 segundos (1 ping/s) en un archivo batch (consume menos CPU): ping -n 6 127.0.0.1>nul
Finalmente,
también es posible arrancar un PC de forma remota mediante una aplicación
WakeOnLAN
04/05/2021 - Utilizar caracteres especiales (unicode) en Matlab
>> disp( [ sprintf(
'\x03B1' )
' = ' num2str(90)
'º, ' sprintf(
'\x03B2' )
' = ' num2str(45)
'º, ' sprintf(
'\x03C9' )
' = ' num2str(-12.5)
'º' ] )
α = 90º, β = 45º, ω = -12.5º
>> disp([ char( 916 )
't = 0, ' char(hex2dec(
'0394' ))
't = 0' ] )
Δt = 0, Δt = 0
Unicodes UTF-8: Greek and Coptic
07/11/2019 - Math Notepad
Math Notepad una sorprendente calculadora
online con capacidades gráficas muy interesantes. Permite realizar cálculos y definir variables y funciones muy fácilmente:
Web online:
http://mathnotepad.com/
Y si se quiere tener el (simple pero fantástico) programa (del mismo autor) para Windows que inspiró esta implementación en web:
http://www.speqmath.com/
04/10/2019 - Solució matricial de sistemes d'equacions amb Matlab
Exemple de sistema d'equacions:
9·X1 + 3·X2 + 4·X3 = 7
4·X1 + 3·X2 + 4·X3 = 8
1·X1 + 1·X2 + 1·X3 = 3
(Solució: X1 = -0.2, X2 = 4.0, X3 = -0.8)
Sistema expressat en format matricial Matlab: A·X = B
>> A = [9 3 4; 4 3 4; 1 1 1];
>> B = [7 8 3]';
Solució mitjançant càlcul numèric directe
Calculant la inversa de A:
>> X = A\B
X = -0.2000 4.0000 -0.8000
Solució mitjançant càlcul numèric directe
Calculant la pseudo-inversa de A:
>> X = pinv(A)*B
X = -0.2000 4.0000 -0.8000
15/03/2011 - Calc 1.0
calc.m
Ejemplos de uso:
[AC] [1000] [+] [18] [%] [=] 1180
[AC] [1000] [+] [18] [±] [%] [=] 820
[AC] [1000] [-] [18] [%] [=] 820
[AC] [100] [+] [10] [=] 110
[AC] [100] [+] [10] [±] [=] 90
[AC] [100] [+] [10] [C] [20] [=] 120
[AC] [100] [+] [10] [=] 110 [=] 120 ( [=] repeats the last operation)
Also available at File Exchange as: https://es.mathworks.com/matlabcentral/fileexchange/30747-calc
30/12/2009 - pen.m for pen or mouse draw input template
Función que permite una entrada por pen o mouse y que está configurada para llamar a la función
process_data(x_pen,y_pen) al pasar por encima de las zonas rojas.
La función es interna, ahora solo muestra el número de datos y está pensada para que se pueda insertar un codigo para procesar el dibujo o escritura.
La funcion
process_data(x_pen,y_pen) se encuentra al final de la función.
>>
pen.m
Also available at File Exchange as: http://www.mathworks.com/matlabcentral/fileexchange/26225
© Laboratori de Robòtica, Universitat de Lleida