function [Successful, nmv, ny, nmd, Ts, p, nx, nxQP] = mpc_getdimensions_multiple(mmpcblock, mpcobj)
% Obtain nmv, nmo, nmd and Ts from existing MPC object in a MMPC block.

%   Author: A. Bemporad
%   Copyright 1986-2011 The MathWorks, Inc.

Successful = false;
mpcobj = controllib.internal.util.hString2Char(mpcobj);
if isa(mpcobj,'char')
    try %#ok<*TRYNC>
        mpcobj = slResolve(mpcobj, mmpcblock);
        Successful = ~isempty(mpcobj);
    end
elseif isa(mpcobj,'mpc') && ~isempty(mpcobj)
   Successful = true;
end
if Successful
    nmd = getNMD(mpcobj);
    nmv = getNMV(mpcobj);
    ny = getNY(mpcobj);
    Ts = mpcobj.Ts;
    p = mpcobj.PredictionHorizon;
    nx = getNX(mpcobj);
    nxQP = getNXQP(mpcobj);
    if isempty(nx)
        % force initializing mpcdata to obtain NX and NXQP due to MaskEvalMove=true
        mpcobj = update(mpcobj);
        nx = getNX(mpcobj);
        nxQP = getNXQP(mpcobj);
    end
else
    nmd = 1;
    nmv = 1;
    ny = 1;
    Ts = 1;
    p = 1;
    nx = 1;
    nxQP = nx;
end
