Artifact c8d8dac4990846c161aefb3f8245ca10d6473f8ab80cae2c8da56d682645bffd:
- Executable file
mttroot/mtt/bin/trans/m/mtt2sys.m
— part of check-in
[19e7f14adf]
at
2002-08-21 18:01:01
on branch origin/master
— Fixed [598316] mtt2sys broken on Octave-2.1.36.
Tests for Octave version that is not 2.0.x, uses setsyssignals() instead of
direct access to internal structure for renaming of system signals. (user: geraint@users.sourceforge.net, size: 1689) [annotate] [blame] [check-ins using] [more...]
function sys = mtt2sys (Name,par) ## usage: sys = mtt2sys (Name[,par]) ## ## Creates a sys structure for the Octave Control Systems Toolbox ## from an MTT system with name "Name" ## Optional second argument is system parameter list ## Assumes that Name_sm.m, Name_struc.m and Name_numpar.m exist ## Copyright (C) 2000 by Peter J Gawthrop if nargin<1 error("missing system name, usage: sys = mtt2sys (Name)"); else ## Create function names numpar_name = sprintf("%s_numpar",Name); sm_name = sprintf("%s_sm",Name); struc_name = sprintf("%s_struc",Name); endif if nargin<2 # Use predefined parameters mtt(Name,"numpar"); eval(sprintf("par=%s_numpar;", Name)); # Parameters mtt(Name,"sm"); # Create state matrices mtt(Name,"struc"); # Create structure info mtt(Name,"sympar"); # Create sympar details else # Only create other file if not there if exist(sm_name)!=2 mtt(Name,"sm"); # Create state matrices endif if exist(struc_name)!=2 mtt(Name,"struc"); # Create state matrices endif endif eval(sprintf("[A,B,C,D]=%s_sm(par);", Name)); # State matrices sys = ss2sys(A,B,C,D); # Sys form if (rindex(version,"2.0.")) # stable (pre-list) eval(sprintf("[sys.inname,sys.outname,sys.stname]=%s_struc;", Name)); # Setup names else # development version eval(sprintf("[mtt_inname,mtt_outname,mtt_stname]=%s_struc;",Name)); # Setup names eval(sprintf("sys = syssetsignals(sys,\"in\", mtt_inname)")); eval(sprintf("sys = syssetsignals(sys,\"out\",mtt_outname)")); eval(sprintf("sys = syssetsignals(sys,\"st\", mtt_stname)")); endif endfunction