function idplot(z,int,T,ny,PC)
%IDPLOT	Plots input - output data.
%	IDPLOT(Z)   or   IDPLOT(Z,INT)
%
%	Z is the input - output data [y u]. This is plotted with output over
%	input. The data points specified in the row vector INT are selected.
%	The default value is all data.
%	If the sampling interval is T, correct time axes are obtained by
%
%	IDPLOT(Z,INT,T)
%
%	If the data is multi-output, appropriate plots are obtained by
%
%	IDPLOT(Z,INT,T,NY)
%
%	where NY is the number of outputs, i.e the ny first columns of Z.
%
%	It is assumed that the input is piecewise constant between sampling
%	instants, and it is plotted accordingly. If linear interpolation
%	between input data points is preferred, use
%	
%	IDPLOT(Z,INT,T,NY,'LI')

%	L. Ljung 87-7-8, 93-9-25
%	Copyright (c) 1986-95 by The MathWorks, Inc.
%	$Revision: 1.4 $  $Date: 1995/05/16 09:01:05 $

if nargin < 1
   disp('Usage: IDPLOT(DATA)')
   disp('       IDPLOT(DATA,INTERVAL,T,No_OF-OUTPUTS,STAIRS)')
   disp('       STAIRS is one of ''PC'', ''LP''.')
   return
end
if nargin<5, PC='PC';end, if isempty(PC),PC='PC';end
if nargin<4, ny=1;end,if isempty(ny),ny=1;end
if nargin<3, T=1;end,if isempty(T),T=1;end,if T<0,T=1;end
if nargin<2, int=1:length(z(:,1));end
if isempty(int),int=1:length(z(:,1));end
[N,nz]=size(z);nu=nz-ny;
newplot;
if nz==ny
   for kk=1:nz
       plot(T*int,z(int,kk))
       title(['OUTPUT # ',int2str(kk)])
       if kk<nz,pause,end
   end
   return
end

for ky=1:ny
for ku=1:nu
   newplot;
   subplot(211),plot(T*int,z(int,ky))
   title(['OUTPUT #',num2str(ky)])
   if PC~='PC',subplot(212),plot(T*int,z(int,ny+ku)),end
   if PC=='PC'
   	ax=axis;
	xa(1:2:2*length(int)-1)=T*int;
	xa(2:2:2*length(int)-1)=T*int(2:length(int));
	ya(1:2:2*length(int)-1)=z(int,ny+ku);
	ya(2:2:2*length(int)-1)=z(int(1:length(int)-1),ny+ku);
	y1=min(ya);y1=y1-0.1*abs(y1);
	y2=max(ya);y2=y2+0.1*abs(y2);
	subplot(212),plot(xa,ya)
	axis([ax(1:2) y1 y2]);
    end
    title(['INPUT #',num2str(ku)])
    if ky+ku<nz,pause,end
end
end

set(gcf,'NextPlot','replace');

