I am beginner to Simulink and had a few experience in Matlab before. My question is the following. Is every Simulink model such as battery,resistor has a special code dedicated to them. For example if i had 2 batteries, do they have different codes such as nominal_voltage1 and nominal_voltage2 that i can change while making simulation if a certain voltage level exceeds?
Each configurable block in simulink can be configured with a unique or common variable.
Below is a simple workspace with 5 constant block. The constant block was chosen because the block mask updates with the configured variable.
Constant is set to 1 Constant1 is set to 10 Constant2 is set to variable foo Constant3 is set to variable foo Constant4 is set to variable bar
The variables foo and bar can be set in the matlab workspace OR via a datadictionary. because constant2 and constant3 use the same variable they will output the same constant.
This is the same for all configurable blocks so you can easily add two batteries and configure each one with a value of nominal_voltage1 & nominal_voltage2, set these two variables in the matlab workspace (say via an m-file) and they will be independent.
As to underlying code... Simulink is proprietary, they do not show you the code. The Simscape area does use their new scripting language for physics base calculations and a lot of those blocks have viewable source