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: mrdivide.m
    path of file: ./repos/chebfun/@chebtech
    
    the code of the file until where you have to start completion: function X = mrdivide(A, B)
%/   Right matrix divide for a CHEBTECH.
%
%   A/B divides the CHEBTECH A by a scalar B. More generally, it gives the

    
function X = mrdivide(A, B)
%/   Right matrix divide for a CHEBTECH.
%
%   A/B divides the CHEBTECH A by a scalar B. More generally, it gives the
%   least-squares solution (with respect to the continuous L^2 norm) to X*B = A
%   when either A or B is a CHEBTECH.  Note that in the latter case, formally
%   it is X.' that is returned, as CHEBTECH objects are always columns.
%
% See also QR, RDIVIDE, MLDIVIDE.

% Copyright 2017 by The University of Oxford and The Chebfun Developers.
% See http://www.chebfun.org/ for Chebfun information.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Case B is a matrix: X*B = A  ==> X = A/B = (Q*R)/B = Q*(R/A) 
%
% Case A is a matrix: X*B = X*(Q*R) = A ==> X = (A/R)*Q' ==> X' = Q*(A/R)'
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if ( (size(B, 2) ~= size(A, 2)) && ~(isa(B, 'double') && isscalar(B)) )
    error('CHEBFUN:CHEBTECH:mrdivide:size', 'Matrix dimensions must agree.');
elseif ( isa(B, 'double') )  % CHEBTECH / double
    if ( ~any(B(:)) )  
        X = A.make(NaN(1, size(A, 2)));
    elseif ( isscalar(B) )
        % Scalar case is easy:
        X = A;                              % Copy A to X
        X.coeffs = A.coeffs/B;              % Divide coeffs
    else
        % For matrix case, we do least squares via QR:
        [Q, R] = qr(A, 0);
        X = Q*(R/B);
    end