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: struct_matvec.m
    path of file: ./repos/imtsl/libs/tensorlab
    
    the code of the file until where you have to start completion: function [x,state] = struct_matvec(z,task,mat,mat2)
%STRUCT_MATVEC Matrix-vector and matrix-matrix product.
%   [x,state] = struct_matvec(z,[],mat) computes x as the matrix-vector (or
%   matrix-matrix) product mat*z. The structure state stores information
%   which is reused in computing the right and left Jacobian-vector
%   products.
%
%   [x,state] = struct_matvec(z,[],mat,mat2) computes x as the

    
function [x,state] = struct_matvec(z,task,mat,mat2)
%STRUCT_MATVEC Matrix-vector and matrix-matrix product.
%   [x,state] = struct_matvec(z,[],mat) computes x as the matrix-vector (or
%   matrix-matrix) product mat*z. The structure state stores information
%   which is reused in computing the right and left Jacobian-vector
%   products.
%
%   [x,state] = struct_matvec(z,[],mat,mat2) computes x as the
%   matrix-matrix product mat*z*mat2. Alternatively, set mat equal to the
%   empty matrix [] to compute x as z*mat2.
%
%   struct_matvec(z,task,mat,mat2) computes the right or left
%   Jacobian-vector product of this transformation, depend