You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: plssquash.m
    path of file: ./repos/CanlabCore/CanlabCore/Statistics_tools
    
    the code of the file until where you have to start completion: function [V, S, varexp, w, Yhat] = plssquash(X, Y, varargin)
% Decomposes data X into K components that are ordered in their 
% covariance with Y, designed to predict orthogonal parts of Y
%
% :Usage:
% ::
%
%     [V, S, varexp, w, Yhat] = plssquash(X, Y, varargin)
%
% :Optional Inputs:
%   - case {'noplot'}, turn off plotting
%   - case 'ndims', save only first ndims (K) vectors
%
% :Outputs:
%
%   **V:**
%        'eigenvetors', or weights, on data (columns)

    
function [V, S, varexp, w, Yhat] = plssquash(X, Y, varargin)
% Decomposes data X into K components that are ordered in their 
% covariance with Y, designed to predict orthogonal parts of Y
%
% :Usage:
% ::
%
%     [V, S, varexp, w, Yhat] = plssquash(X, Y, varargin)
%
% :Optional Inputs:
%   - case {'noplot'}, turn off plotting
%   - case 'ndims', save only first ndims (K) vectors
%
% :Outputs:
%
%   **V:**
%        'eigenvetors', or weights, on data (columns)
%
%   **S:**
%        score matrix, N x K
%
%   **varexp:**
%        sqrt(r-square) with first k components predicting Y
%
%   **w:**
%        V*b, integrated weights.  for predicting new data, pred = X*w
%
%   **Yhat:**
%        X*V*b, or S*b
%
% ..
%    Tor Wager, 9/12/09
% ..

doplot = 1;
ndims = length(Y) - 1; 

for i = 1:length(varargin)
    if ischar(varargin{i})
        switch varargin{i}
            case {'noplot'}, doplot = 0;
            case 'ndims', ndims = varargin{i + 1};
                
            otherwise, warning(['Unknown input string option:' varargin{i}]);
        end