function data = mpc_previewer_maskinit(signal,ts)
% MPC_PREVIEWER_MASKINIT  resample the signal with sample time.
%
 
% Author(s): Rong Chen 21-Sep-2011
% Copyright 2011 The MathWorks, Inc.

value = signal.signals.values; % column is the time axis
time = signal.time; % column vector
if time(1)~=0
    ctrlMsgUtils.error('MPC:utility:SignalPreviewerSampleTimeError');
end
data = interp1(time,value,(0:ts:time(end))');
for ct=2:size(data,1);
    data(ct,:) = value(sum((ct-1)*ts>=time),:);
end
data = [data; value(end,:)];
