- Internal states, i.e., states that are introduced by Simscape as part of the compilation process, may have a number following the name in order to ensure uniqueness of the state names. These are "secondary variables" and usually it shouldn't be necessary to set the values on those states explicitly (although maybe not always).
- In the "Model Settings", you should be able to go to "Data Import/Export" and select "Final states" and "Save final operating point". Then, after running the model, you can look at xFinal.loggedStates.stateName to get all of the state names that Simulink sees.
Modifying Simscape Initial Conditions
    15 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Christopher Slack
 am 29 Mai 2025
  
    
    
    
    
    Kommentiert: Christopher Slack
 am 12 Jun. 2025
            We receive a simscape plant model together with a .mat file containing the initial conditions.
We want to place that simscape model into a subsystem, connect it to a controller model, and save the combined model as a different model name.
The Initial Conditions variable is a structure array with .signals.blockName and .signals.stateName fields containing the full path of the simscape blocks.  For example
>> disp(InitialConditions.signals(10).blockName)
Architecture_Delivery2/C11/Bulk Heater
and
>> disp(MissionProfile_InitialConditions.signals(10).stateName)
Architecture_Delivery2.C11.Bulk_Heater.BH_3_.p_I
All well and good - I've written a simple function to strrep() from the original model/path names to the new model/path names.  This works most of the time.  However occasionally I see a stateName like this:
>> disp(InitialConditions.signals(2).stateName)
Architecture_Delivery2.Simulink_PS_Converter14.outputFiltered_3445558726_0
and when I save the model, the numbers at the end can change (sometimes, not always).  This means that the model fails to initialise as it can't find the correct stateName.
Unable to load the specified initial state for model 'Combined_Plant_Controller'. BlockName/BlockPath of the element at index 2 in the initial state is invalid
Note that this error is incorrect - it's not the Block Name/Path that's incorrect but the State Name/Path.
So, my questions are;  
- Why do some blocks have seemingly random numbers appended to the stateName and others don't?
- Is there a way to programmatically examine a model to find out what number has been given to a block's stateName so that I can update the initial conditions variable correctly?
0 Kommentare
Akzeptierte Antwort
  David John
    
 am 9 Jun. 2025
        Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Physical Units finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

