Error "Undefined function or variable" when starting Simulink
2 views (last 30 days)
I'm currently using R2012b and get an error "Undefined function or variable 'delta_t'." when my function starts a Simulink Model (The Model was not made by me).
When I set a Breakpoint a this part of the function:
simout = sim(sim_pathfile,'SrcWorkspace','current');
I see the workspace of the function and there is a 1x1double variable called "delta_t" and the Base Workspace is empty. In this case I get the error "Undefined function or variable 'delta_t'."
If I define a variable "delta_t" in the Command Window before starting the function (so there is a variable "delta_t" in the Base Workspace), the Simulation starts and works fine. In this case, there are all the relevant variables in the function workspace and only the "delta_t" variable is in the function and the Base workspace.
So far it looks like the simulation uses the function workspace, as I defined it with:
And only for the delta_t variable it uses the Base workspace.
Now the part, where I stopped understanding anything:
I started to set the variable "delta_t" with various values in the function workspace (the variable "delta_t" in the Base workspace stays the same) when I looked at the results of the simulation, I saw that the simulation uses the value of the "delta_t" variable in the function workspace.
Could it be that the Simulink Model looks at the Base workspace if the variable "delta_t" is there (I do not understand why it does this only for this one variable and non of the others, it is using) and then uses the "delta_t" variable of the function workspace?
I hope it was understandable and I am not doing some really stupid mistake.
Thank you in advance