Home > m > timetools > statespacefunctions > utp_ltpda_ss_random_generate.m

utp_ltpda_ss_random_generate

PURPOSE ^

utp_ltpda_ss_random_generate subfunction generates a random system

SYNOPSIS ^

function syst = utp_ltpda_ss_random_generate(nSysTot, pSys, nUTot, OutputSizes, InputSizes)

DESCRIPTION ^

 utp_ltpda_ss_random_generate subfunction generates a random system
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: utp_ltpda_ss_random_generate subfunction generates randomly
 a p-th system out of nSysTot systems, with nUTot exogenous inputs,
 nSysTot possible 'inner' inputs, OutputSizes and InputSizes neing the
 respective sizes of the output sizes of the pSys systems and sizes of the
 nUTot input streams.

 CALL: utp_ltpda_ss_random_generate

 INPUTS: none

 OUTPUTS: 1/0

 ***** THERE ARE NO DEFAULT PARAMETERS *****

 VERSION: $Id: utp_ltpda_ss_random_generate.m,v 1.2 2008/02/20 09:20:07 adrien Exp $

 HISTORY: 22-01-2008 A Grynagier

 TO DO : Nothing
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function syst = utp_ltpda_ss_random_generate(nSysTot, pSys, nUTot, OutputSizes, InputSizes)
0002 % utp_ltpda_ss_random_generate subfunction generates a random system
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 %
0005 % DESCRIPTION: utp_ltpda_ss_random_generate subfunction generates randomly
0006 % a p-th system out of nSysTot systems, with nUTot exogenous inputs,
0007 % nSysTot possible 'inner' inputs, OutputSizes and InputSizes neing the
0008 % respective sizes of the output sizes of the pSys systems and sizes of the
0009 % nUTot input streams.
0010 %
0011 % CALL: utp_ltpda_ss_random_generate
0012 %
0013 % INPUTS: none
0014 %
0015 % OUTPUTS: 1/0
0016 %
0017 % ***** THERE ARE NO DEFAULT PARAMETERS *****
0018 %
0019 % VERSION: $Id: utp_ltpda_ss_random_generate.m,v 1.2 2008/02/20 09:20:07 adrien Exp $
0020 %
0021 % HISTORY: 22-01-2008 A Grynagier
0022 %
0023 % TO DO : Nothing
0024 %
0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0026 display(['starting ' mfilename]);
0027 VERSION =  '$Id: utp_ltpda_ss_random_generate.m,v 1.2 2008/02/20 09:20:07 adrien Exp $';
0028 
0029 TYPE = 'SUBSYSTEM';
0030 NAME = ['Y_', num2str(pSys)];
0031 INPUTNAMES = {};
0032 NBINPUTS_exo = floor((nUTot+1)*rand);
0033 NBINPUTS_in = floor((nSysTot+1)*rand);
0034 NBINPUTS = NBINPUTS_exo + NBINPUTS_in ;
0035 InputsexoVals = ones(NBINPUTS_exo,1) + floor(nUTot*rand(NBINPUTS_exo,1));
0036 InputsInVals = ones(NBINPUTS_in,1) + floor(nSysTot*rand(NBINPUTS_in,1));
0037 for i=1:NBINPUTS_exo
0038     INPUTNAMES = [INPUTNAMES ['U_',num2str(InputsexoVals(i))]];
0039 end
0040 for i=1:NBINPUTS_in
0041     INPUTNAMES = [INPUTNAMES ['Y_',num2str(InputsInVals(i))]];
0042 end
0043 INPUTISUSED = floor(2*rand(NBINPUTS,1));
0044 %time representation for the matrices, given by the timestep for discrete
0045 %case and by a 0 for a time continuous representation
0046 TIMESTEP = 0;  %to be randomized !!!
0047 %declaration of the symbollic variables TO CHANGE AND LOAD DATA FROM A
0048 %PLIST (WRITE FUNCTION TO *MODIFY* THE PLIST SEPARATELY)
0049 NBPARAMS = floor(10*rand);
0050 PARAMNAMES = cell(NBPARAMS,1);
0051 PARAMVALUES = randn(NBPARAMS,1);
0052 PARAMSIGMAS = rand(NBPARAMS,1);
0053 for i=1:NBPARAMS
0054     PARAMNAMES{i} = ['Param_Y', num2str(pSys),'_',num2str(i)];
0055 end
0056 %declaring the symbolic variables
0057 for indice=1:length(PARAMNAMES)
0058     declaration = [  eval(['PARAMNAMES{', num2str(indice),  '}']) , '=sym( ''', eval(['PARAMNAMES{' , num2str(indice), '}']) , ''');'];
0059     eval(declaration);
0060 end
0061 %Making sure no reserved parameter is used
0062 for i=1:length(PARAMNAMES)
0063     if ( (isequal(PARAMNAMES{i},'z')==1) || (isequal(PARAMNAMES{i},'t')==1) || (isequal(PARAMNAMES{i},'T')==1) || (isequal(PARAMNAMES{i},'s')==1) )
0064         msg = ['wrong (reserved for time/frequency) name for variable "',  PARAMNAMES{i}, '" in MatModel from file : ', NAME];
0065         error(msg)
0066     end
0067 end
0068 %Size of state space
0069 nss = floor(abs(2*randn(1)));
0070 A = randn(nss,nss);
0071 C = rand(OutputSizes(pSys),nss);
0072 AMAT = {A};
0073 CMAT = {C};
0074 BMATS = cell(NBINPUTS,1);
0075 DMATS = cell(NBINPUTS,1);
0076 for i=1:NBINPUTS_exo
0077     BMATS{i} = rand(nss,InputSizes(InputsexoVals(i)));
0078     DMATS{i} = rand(OutputSizes(pSys),InputSizes(InputsexoVals(i)));
0079 end
0080 for i=1:NBINPUTS_in
0081     BMATS{i+NBINPUTS_exo} = rand(nss,OutputSizes(InputsInVals(i)));
0082     DMATS{i+NBINPUTS_exo} = rand(OutputSizes(pSys),OutputSizes(InputsInVals(i)));
0083 end
0084 INPUTSIZES = zeros(length(BMATS),1);
0085 for i=1:length(BMATS)
0086     INPUTSIZES(i)= size(BMATS{i},2);
0087 end
0088 XISOUTPUT=floor(2*rand);
0089 YISOUTPUT=floor(2*rand);
0090 XINI = rand(nss,1);
0091 
0092 syst = plist('TYPE', TYPE ,'NAME', NAME ,'TIMESTEP', TIMESTEP , ...
0093     'XISOUTPUT',XISOUTPUT,'YISOUTPUT',YISOUTPUT,'XINI', XINI , ...
0094     'PARAMNAMES', PARAMNAMES ,'PARAMVALUES', PARAMVALUES ,'PARAMSIGMAS', PARAMSIGMAS ,...
0095     'NBINPUTS', NBINPUTS ,'INPUTNAMES', INPUTNAMES ,'INPUTSIZES', INPUTSIZES , 'INPUTISUSED', INPUTISUSED ,...
0096     'AMAT', AMAT ,'BMATS', BMATS ,'CMAT', CMAT ,'DMATS', DMATS );
0097 %making content tests on the subsystem
0098 ltpda_ss_check(syst);
0099 %erasing useless fields
0100 clear A B C D E F PARAMNAMES PARAMVALUES PARAMSIGMAS
0101 %Saving the workspace in the file named "subsystem_GENERATE_workspaceGenerated".
0102 filename = [mfilename,'_workspaceGenerated'];
0103 save(filename);
0104 end

Generated on Tue 26-Feb-2008 10:52:52 by m2html © 2003