GUI for singular value decomposition demo
Version 1.0.0 (65.5 KB) by Jitong Ding
This GUI can be used for tutorial purpose for demonstrating singular value decomposition on a 2by2 matrix.
Updated 6 Sep 2021
This GUI can be used for tutorial purpose for demonstrating singular value decomposition on a 2by2 matrix. Users can input any 2by2 matrix 'A' and the direction of the 2by1 vector 'x'. The interface will then output the result of the vector 'Ax'. For a certain matrix 'A', choosing vector 'x' of different directions will result in different length of the vector 'Ax'. To get the maximum length of vector 'Ax', the direction of the input vector 'x' should be aligned with the first right singular vector of the matrix 'A'. On the contrary, if the input vector 'x' is in the direction of the the second right singular vector of the matrix 'A', then you will get minimum length of the vector 'Ax'.
To use this GUI, here are the steps:
(1) Open file 'demoforsvd.m' and click Run. (You need to put the other file 'demoforsvd.fig' in the same folder)
(2) Input the four elements for the matrix 'A' in the middle and click 'update'.
(3) Input the coordinates for the vector 'x' at the bottom left of the panel. Note that normalisation will be executed by the code.
(4) Click 'plot' to see the result.
(5) You can repeat (3)&(4) by trying out different vectors 'x'. Or, you can click 'clear' to remove all the existing results.
(1) The red dashed line on the left plot shows the direction of the first right singular vector for the matrix 'A' while the blue dashed line shows the direction of the second right singular vector for the matrix 'A'.
(2) The colour for one chosen vector 'x' will be the same as the colour for the corresponding vector 'Ax'. You can plot as many pairs of 'x' and 'Ax' as you want, since different pairs will be distinguished by different colours.
Jitong Ding (2023). GUI for singular value decomposition demo (https://www.mathworks.com/matlabcentral/fileexchange/98819-gui-for-singular-value-decomposition-demo), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with R2021a
Compatible with any release
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.