function [y,u,v,w,A,B,D,E,C,F] = modsim(STDv,STDw,u3,nt,x0);
%        [y,u,v,w,A,B,D,E,C,F] = modsim(STDv,STDw,u,nt);
% MODSIM Simulate and get state space model matrices for a MIMO
%        system with n = 3 states, m = 2 outputs and r = 2 inputs.
% SYNTAX
%        [y,u,v,w,A,B,D,E,C,F] = modsim(STDv,STDw,u,N);
%        [y,u,v,w,A,B,D,E,C,F] = modsim(STDv,STDw,u,N,x0);
%

if nargin == 4; x0=zeros(3,1); end

u = u3;

A  = [1.5,1.0,0.1;-0.7,0.0,0.1;0,0,0.85];
B  = [0.0 0.0;0.0 1.0;1.0 0.0];
C  = [0.0 0.1;0.1 0.0;0.0 0.2];
D  = [3.0,0.0,-0.6;0.0,1.0 1.0];
E  =-eye(2)*0;
F  = eye(2);
%x0 = [0;0;0];

% rand('seed',0);       % Resets seed to 0

[ny,nx] = size(D);

v = randn(nt,ny)*STDv;
w = randn(nt,ny)*STDw;

y = dsrsim(A,[B,C,zeros(3,2)],D,[E,zeros(2,2) F],[u,v,w],x0);
