function [y, q] = iqr(x,dim)
%MATLAB Code Generation Toolbox Function

%   Copyright 1993-2023 The MathWorks, Inc.
%#codegen

coder.internal.assert(nargin > 0,'MATLAB:minrhs');
if nargin == 1
    qt = prctile(x, [25; 75]);
    y = diff(qt);
    if nargout == 2 && isrow(x)
        % Orient p so that it is also a row vector.
        q = reshape(qt,1,2);
    else
        q = qt;
    end
else
    coder.internal.prefer_const(dim);
    q = prctile(x, [25; 75],dim);
    y = diff(q,[],dim);
end
