I have some processing (moving of wheelset). Wheelset has mass, it’s variable and it’s declaring in init.m file (for example M=1;)
Now I want that in this proccess mass of wheelset will be changed every 2 seconds. How to save the new value of mass to M variable from Simulink?
For me I’ve found the decision.
I’ve used variable
Mfor storing object mass. And from simulink I’ve just called M in function calls. For example:But calling function Rho in

MATLAB Functionblock looks like:This approach works only if M is static. Now I want to change
Mdinamically in time. So, first I’ve decided that I can makeMglobal and change it. I’ve written a function, made a function block which was calculating newMvalue and setting it’s to globalMvariable. But it didn’t work. You can’t at the same time use and change one global variable in Simulink.So I’ve decided to change the whole approach. As
Mis now not static parameter, I should makeMas signal. So now it looks like:Here in block
ConstantMis getting from workspace (or some init.m file) and then Simulink works not withMvariable from workspace, but with local signalM