Simulink FastRestart doesnt change output

23 visualizzazioni (ultimi 30 giorni)
Marcus Heßeling
Marcus Heßeling il 16 Feb 2021
Commentato: Ahmed Fahmy il 7 Feb 2025 alle 14:48
Hey Guys,
i have a simulink model in a for loop. Every Iteration i change parameters in my system. If i run the system without Fast Restart, it changes it outcome as it should. But when i activate FastRestart in my model the output is always the same.
My Code is:
for k=1:3
alpha = [50-k,100+k,125-k,85+k];
s = [3-0.01*k,4+0.01*k,4-0.01*k];
t = [3+0.01*k,4-0.01*k,4+0.01*k];
geometrics = getGeometrics(alpha,s,t); %returns a strucArray. The Geometrics are used as length and angle Parameters in the Simulation
%start simulation
simOut = sim('Model.slx','CaptureErrors','on','SrcWorkspace','current');
%Solution
pos1 = simOut.xx.data;
disp(['Position: ' num2str(pos1), 'cm')]);
end
% The Display in normal like 1cm, 2cm, 3cm and in FastRestart 1cm, 1cm, 1cm
I have no idea why my output doesnt change in FastRestart. In
it is written that all my blocks must support ModelOperatingPoint but i dont know how to check that either.
  3 Commenti
NV
NV il 4 Feb 2025 alle 16:48
I have this same problem, did you manage to find a solution?
Ahmed Fahmy
Ahmed Fahmy il 7 Feb 2025 alle 14:48
I don't recall I had a workaround.

Accedi per commentare.

Risposte (1)

Kothuri
Kothuri il 7 Feb 2025 alle 14:22
The issue you are facing is because in Fast Restart it is not reinitializing parameters that are changed in the MATLAB workspace. When Fast Restart is enabled, Simulink does not reload model parameters from the workspace for each simulation run unless explicitly told to do so.
You cn try the below steps in Fast Restart:
  • To reload workspace variables, you need to explicitly update them using "set_param()" before running the simulation. You can try the below code
for k = 1:3
alpha = [50-k, 100+k, 125-k, 85+k];
s = [3-0.01*k, 4+0.01*k, 4-0.01*k];
t = [3+0.01*k, 4-0.01*k, 4+0.01*k];
geometrics = getGeometrics(alpha, s, t); % Get updated parameters
% Update parameters in the model
set_param('Model', 'FastRestart', 'on'); % Ensure Fast Restart is on
set_param('Model', 'SimulationCommand', 'update'); % Ensure parameters are updated
% Start simulation
simOut = sim('Model', 'CaptureErrors', 'on', 'SrcWorkspace', 'current');
% Solution
pos1 = simOut.xx.data;
disp(['Position: ' num2str(pos1), 'cm']);
end
  • You can also set the variables inside the "model workspace", which can update automatically during Fast Restart.
  • To check if all the blocks support "Fast Restart", you can try the below command
get_param('Model', 'OperatingPointCompliance')
  • This will show whether your blocks support fast restart.
  • If you get "Unknown" or "Unsupported", then some blocks in your model do not support fast restart.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by