Professional Documents
Culture Documents
ThisexampleshowshowtousetheSimulationDataInspectortoviewandanalyzesignalsinreferencedmodels.The
SimulationDataInspectorreliesonsignalloggingsothisexampleshowshowtoconfigureyourmodeltologsignalsin
referencedmodels.
OpentheExampleModels
Runthefollowingcommandtocreateandopenaworkingcopyoftheprojectfiles.
slexMultiInstanceModelStart
Theprojectexamplecopiesfilestoyourtemporaryfoldersothatyoucaneditthemandusethemunderlocalversion
control.
TheSimulinkProjectToolopensandloadstheprojectalreadyunderversioncontrol.
Theprojectisconfiguredtorunsomestartuptasks.
SettingupSignalstoLoginReferencedModels
ThefirsttaskinsettingupareferencedmodeltoviewsignalsusingtheSimulationDataInspectoristosetupthat
modelforlogging.Todothat,editthereferencedmodelandmarkthesignalsforlogging.Notethatfoursignalsare
alreadysetupforlogging(markedwiththeblueantennas).Tologanadditionalsignal:
1.Selecttherawoutputsignal
2.ClicktheSimulinkDataInspectorbuttonandselecttheLogSelectedSignalstoWorkspacemenuitem,as
shownbelow
Oncethesignalstologhavebeenselectedinthereferencedmodel,thenextstepistoselectwhichsignalsto
actuallylogfromthetopmostmodelinthehierarchy.SelectingtheConfigureLoggingandStreaming...menu
itemonthetopmodel'sRecordbuttonactivatestheConfigurationParameters>DataImport/Exportpane.
ClicktheConfigureSignalstoLog...buttontoactivatetheSimulinkSignalLoggingSelectordialog.
TherearetwoLoggingmodesthatcanbeusedwhenloggingsignalsinreferencedmodels.ThefirstisLogall
signalsasspecifiedinmodel,whichwillhonoranyloggingsettingsthatweremadeinreferencedmodels.Ifyou
needtooverrideanyofthosesettings,suchasselectingonlyasubsetofloggedsignals,thenyoushouldusethe
Overridesignalsmode.Inthismode,youaregiventheabilitytoselectasubsetofloggablesignalsandconfigure
theirproperties,suchasdecimationandname.
ViewingandAnalyzingLoggedSignalsUsingtheSimulationDataInspector
Oncelogginghasbeenconfiguredforamodelhierarchyandallchangestothemodelshavebeensaved,themodel
canbesimulated.ThesimulationcreatesaDatasetobjectinthebaseworkspace.Youcananalyzeandviewthe
loggeddatainthisobjectusingstandardMATLABtools.Inaddition,SimulinkprovidestheSimulationDataInspector,
forviewingandanalyzingdatacreatedfromsimulations.Seethedocumentationformoredetailsonusingthe
SimulationDataInspector.
WiththeSimulationDataInspector,youcan:
Viewsignaltracesforanyloggedsignals
Visuallycomparesignalvaluesforanyloggedsignals
Comparesignalvaluescollectedovermultiplesimulations
ToenabletheSimulationDataInspector,makesurethattheRecordbuttononthetoolbarofthetopmostmodelis
toggledonbeforestartingthesimulation.ThenafterasimulationisdoneorwhileusingtheSimulationStepperyouwill
seeahighlightaroundtheRecordbutton,whichindicatesthatclickingitwillopentheDataInspector.
Forexample,youcanusetheSimulationDataInspectortocomparetheoutputsignaloftwooftheinstancesofthe
modelLimitedCounter.Asshownbelow,youcanseethatCounterAincreasesmorerapidlythanCounterB,whichis
expectedbecausethePulseGeneratordrivingthismodelisrunningatafasterrate.
AnotherusefultoolthattheSimulationDataInspectorprovidesistheabilitytocomparemultiplesimulationruns.This
functionalitycanhelpyouunderstandhowchangestoyourmodelwillaffectresults.Forexample,youcanchangethe
valueoftheupperlimitofthecountermodelsto8andsimulatethemodelagaintoseehowthataffectsoutputvalues.
Tochangethevalue,doubleclickontheblockMultiInstanceModelExample/upperandmodifytheValueparameter
to8.
NowifyoucomparetheresultsfromthefirstsimulationfortheoutputoftheCounterAinstanceofLimitedCounter,
youseethattheupperlimitofthissignalhaschangedfrom10to8,asexpected.Theredoctagonnexttoeachsignal
indicatesthatthevalueshavechangedbetweenruns.