Interactive MATLAB tool for learning Principal Component Analysis through hands-on exploration.
One-click launch in MATLAB Online:
[
Alternative access:
Requires free MathWorks account or University account (when prompted to login, insert your @universityname email to access Mathlab for free)
For individuals who have never used mahtlab before: ONCE you are in mahtlab online (or runned locally), in the COMMAND TAB, type 'pca_builder' and it will open the visualization.
PCA is typically taught with formulas and static diagrams. This tool lets you manipulate parameters and immediately see how correlations affect data structure, how principal components emerge, and why they capture variance in specific directions.
Built for students learning multivariate statistics, educators teaching PCA, or anyone who wants to develop geometric intuition for how PCA works.
- Interactive control over means, standard deviations, and correlations
- Multiple visualization stages (1D, 2D, 3D, PCA)
- Click-through animations showing geometric decompositions
- Visual projections onto principal component axes
- Built-in educational reference with statistical formulas
- Preset scenarios demonstrating key concepts
Click the "Open in MATLAB Online" badge above - it will launch directly in your browser.
If you have MATLAB:
Download pca_builder.m and run it:
pca_builderIf you don't have MATLAB:
- Create free account at matlab.mathworks.com
- Download
pca_builder.mfrom File Exchange - Upload to MATLAB Online
- Run:
pca_builder
Free tier provides 20 hours/month.
Start with the "3x1D" stage to see independent variables, then progress to "2D" to observe correlation effects, "3D" for full data cloud visualization, and "PCA" to see principal components.
Use ROTATE mode to adjust view angles, SELECT mode to click points and deviation lines. The HELP button provides comprehensive documentation.
Try setting all correlations to 0.99 to see data collapse onto a line, or to 0 to see a spherical cloud. The "Try This" tab in the help window has preset scenarios.
I learned PCA twice - once in second year during independent research, again in third year coursework. The confusion often stems from lacking geometric intuition about variance, standard deviation, and how these concepts extend to multiple dimensions.
This tool won't teach linear algebra from scratch, but aims to make the geometric relationships visual and manipulable. PCA requires thinking in multiple dimensions, which is conceptually challenging. Hopefully this makes it slightly easier.
For deeper understanding of the underlying math, I recommend 3Blue1Brown's linear algebra series on YouTube.
If you use this in teaching or research:
APA:
Bechara, S. (2025). PCA Builder & Visualization: An Interactive Tool
for Understanding Principal Component Analysis [Computer software].
MATLAB Central File Exchange. Retrieved from
https://www.mathworks.com/matlabcentral/fileexchange/182686
BibTeX:
@software{bechara2025pca,
author = {Bechara, Sacha},
title = {PCA Builder \& Visualization: An Interactive Tool for
Understanding Principal Component Analysis},
year = {2025},
publisher = {MATLAB Central File Exchange},
url = {https://www.mathworks.com/matlabcentral/fileexchange/182686}
}Bug reports, feature requests, and improvements welcome. Open an issue or submit a pull request.
MIT License - free to use and modify. If you improve it, consider contributing back.
- GitHub Repository: https://github.com/sachabechara/pca-visualization-tool
- MATLAB File Exchange: https://uk.mathworks.com/matlabcentral/fileexchange/182686
- Author: Sacha Bechara
Built to make PCA more accessible and visually intuitive.
















