MATLAB: Simulink animation for BLDC motors

animate simulinksimulink

Hi my name is Beniamin and I am trying to simulate a BLDC motor design in simulink as is shown in this MathWorks video:
https://es.mathworks.com/videos/how-to-design-motor-controllers-using-simscape-electrical-part-1-simulating-back-emf-voltage-of-a-bldc-motor-1565241566392.html
When I try to animate the simulation by the function 'simulate', Matlab does not recognise it.
>> animateRotorPosition
Unrecognized function or variable 'animateRotorPosition'.
I am using a MATLAB R2019b – academic use version.
Thank you

Best Answer

I didn't see anything about animate in that video. however I propose after running the simulation, save your data including time vector to workspace. then using this code you can animate the plot. for example you want to plot flux vector vs rotor position at each time sample:
n = length(time); % number of samples
% theta_r = rotor position
% psi = flux
for i=1:n
% plot your data here
plot(theta_r(i),psi(i))
drawnow
end
Related Question