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: lmlra_hooi.m
    path of file: ./repos/imtsl/libs/tensorlab
    
    the code of the file until where you have to start completion: function [U,S,output] = lmlra_hooi(T,U0,options)
%LMLRA_HOOI LMLRA by higher-order orthogonal iteration.
%   [U,S,output] = lmlra_hooi(T,U0) computes the factor matrices U{1}, ...,
%   U{N} and core tensor S belonging to a low multilinear rank
%   approximation of the N-th order tensor T. The algorithm is initialized
%   with the factor matrices U0{n}. The structure output returns additional
%   information:
%
%      output.info       - The circumstances under which the procedure
%                          terminated:
%                             1: Objective function tolerance reached.
%                             2: Maximum number of iterations reached.
%      output.iterations - The number of iterations.
%      output.normS      - The Frobenius norm of the core tensor S in each
%                          iteration.
%      output.sangle     - The difference in subspace angle of U{1} between
%                          every two successive iterates.
%
%   lmlra_hooi(T,U0,options) may be used to set the following options:
%
%      options.MaxIter = 500 - The maximum number of iterations.
%      options.TolFun = 1e-6 - The tolerance for difference in subspace
%                              angle of U{1} between two successive
%                              iterates.


    
function [U,S,output] = lmlra_hooi(T,U0,options)
%LMLRA_HOOI LMLRA by higher-order orthogonal iteration.
%   [U,S,output] = lmlra_hooi(T,U0) computes the factor matrices U{1}, ...,
%   U{N} and core tensor S belonging to a low multilinear rank
%   approximation of the N-th order tensor T. The algorithm is initialized
%   with the factor matrices U0{n}. The structure output returns additional
%   information:
%
%      output.info       - The circumstances under which the procedure
%                          terminated:
%                             1: Objective function tolerance reached.
%                             2: Maximum number of iterations reached.
%      output.iterations - The number of iterations.
%      output.normS      - The Frobenius norm of the core tensor S in each
%                          iteration.
%      output.sangle     - The difference in subspace angle of U{1} between
%                          every two successive iterates.
%
%   lmlra_hooi(T,U0,options) may be used to set the following options:
%
%      options.MaxIter = 500 - The maximum number of iterations.
%      options.TolFun = 1e-6 - The tolerance for difference in subspace
%                              angle of U{1} between two successive
%                              iterates.

%   Authors: Laurent Sorber (Laurent.Sorber@cs.kuleuven.be)
%            Lieven De Lathauwer (Lieven.DeLathauwer@kuleuven-kulak.be)
%
%   References:
%   [1] P.M. Kroonenberg, J. de Leeuw, "Principal component analysis of
%       three-mode data by means of alternating least squares algorithms",
%       Psychometrika, Vol. 45, 1980, pp. 69-97.
%   [2] L. De Lathauwer, B. De Moor and J. Vandewalle, "On the best rank-1
%       and rank-(R1,R2,...,RN) approximation of higher-order tensors",
%       SIAM J. Matrix Anal. Appl., Vol. 21, 2000, pp. 1324-1342.
%   [3] P.M. Kroonenberg, "Applied Multiway Data Analysis", Wiley, 2008.

% Check the tensor T.
N = ndims(T);
if N < 3
    error('lmlra_hooi:T','ndims(T) should be >= 3.');
end