Matlab Pls Toolbox →

One of the toolbox’s most acclaimed features is its Graphical User Interface (GUI) . The GUI is not an afterthought but a carefully designed environment that allows users to build, analyze, and manage models without writing a single line of code. The main interface, launched by typing plstoolbox in MATLAB, consists of several linked windows:

This GUI lowers the barrier to entry for non-programmers (e.g., lab chemists, quality control technicians) while providing expert users with rapid prototyping capabilities. It embodies a "learn by doing" approach: one can explore preprocessing options visually and only later script the optimal workflow for automation.

Raw spectra contain physical noise (scatter, baseline drift). Always apply at least Mean Center and consider SNV or MSC for reflectance data. Use the preprocess GUI to explore different sequences.

Problem: A refinery wants to predict the octane number of gasoline from NIR spectra (1100–2500 nm). Standard linear regression fails due to collinearity.

Solution using MATLAB PLS Toolbox:

Code snippet:

analysis_launch;  % Interactive GUI used for initial exploration
% Export to script:
pls_model = pls(X_snv_sg, Y_octane, 4, 'crossval', 'venetian');
validation_result = predict(pls_model, X_valid);
figure; plot(Y_valid, validation_result.pred1, 'ro'); refline(1,0);
xlabel('Reference Octane'); ylabel('Predicted Octane');
  • sPLS per component

  • Normalize w_h, compute score t_h = X_res * w_h, estimate loadings p_h and q_h, deflate X and Y.
  • Hyperparameter selection (outer CV)

  • Final fit

  • Utilities

  • The PLS Toolbox emerged during a pivotal era in analytical chemistry. In the 1980s and early 1990s, techniques like Near-Infrared (NIR) and Mid-Infrared (MIR) spectroscopy were gaining traction for rapid, non-destructive analysis. These techniques produced hundreds or thousands of wavelengths per sample, creating data matrices where the number of variables (p) often far exceeded the number of samples (n). Traditional regression methods like Multiple Linear Regression (MLR) failed due to collinearity, while Principal Component Regression (PCR) could ignore the response variable (e.g., concentration of an analyte) during the decomposition step.

    Herman Wold and Svante Wold’s development of Partial Least Squares (PLS) offered a solution: a latent variable method that simultaneously decomposes the predictor matrix X and the response matrix Y, maximizing the covariance between them. However, in the early 1990s, no integrated, user-friendly software existed to apply these advanced algorithms to real-world data. Researchers were forced to write custom scripts in Fortran, C, or the emerging MATLAB, which itself was gaining popularity in engineering and science for its matrix-based syntax.

    Enter Eigenvector Research. Founded by Barry M. Wise, a former Ph.D. student of Svante Wold’s, the company recognized the gap. The PLS Toolbox was first released in 1992 as a set of scripts that not only implemented the core algorithms (NIPALS, SIMPLS) but also provided critical diagnostic plots and preprocessing methods. Its initial success was driven by the synergistic combination of MATLAB’s computational backbone and the toolbox’s domain-specific intelligence. This synergy remains the toolbox’s defining characteristic. matlab pls toolbox

    Not all spectral wavelengths are useful. The PLS Toolbox automatically computes Variable Importance in Projection (VIP) scores.

    % After building a model
    vip_scores = vip(model);
    % Find indices of critical variables (VIP > 1)
    critical_vars = find(vip_scores > 1);
    % Plot spectra highlighting critical regions
    plotw(X_obj, 'color', 'k');
    hold on;
    plotw(X_obj(:, critical_vars), 'color', 'r', 'linewidth', 2);
    

    | Feature | MATLAB PLS Toolbox | MATLAB plsregress | Python (scikit-learn) | | :--- | :--- | :--- | :--- | | GUI | Yes (interactive) | No | No | | Preprocessing | 40+ chemometric methods | None | Limited (via Pipelines) | | Cross-validation | 10+ methods (auto-config) | Manual implementation | Via cross_val_predict | | Contribution Plots | Yes (one-click) | No | Requires manual coding | | Regulatory Support | Yes (21 CFR Part 11) | No | No | | Cost | High (Commercial) | Included in base | Free |

    To effectively use the MATLAB PLS Toolbox, you must understand how it structures data. The toolbox relies on the Dataset Object—a class that holds not just the numeric matrix, but also axis scales, labels, and included/excluded rows.

    >