My simulink model seems to not receiving proper variables from workspace or not returning proper value to workspace.
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Wiktor Jachym
el 13 de Nov. de 2020
Comentada: Carsten Prokopp
el 24 de En. de 2021
I have following problem. I made simulink model, it's simple AC-DC rectifier. Everything works proper until I want to do some research how various value of inductance affects current. I implemented a script, that changes value of inductance in for loop. These values are changing properly because I tested it. After change of inductance value, I'm executing simulink model by function sim() and then I want to get info about current from simulink model, plot it to figure and go to next value of inductance. Instead of this, I'm getting exact values. I was tried to save workspace variables to separated files, and I realised, these values was always the same. So, my question is, how to save data from simulink model with various values of inductance.
4 comentarios
Respuesta aceptada
Fangjun Jiang
el 13 de Nov. de 2020
I am trying to find the document link but could't. I thought it was in "doc sim".
The problem could be explained by the way sim() is called in the script. Imagine it takes a long time for the model to finish one simulation, the for-loop is not going to wait for the finish of sim() line and then execute the next line. It is just going to issue the sim() command and then moves on to the next loop.
If you gives a return variable to sim() line, it is going to force it to finish and log the return variable. You then can have the expected results.
for i = 1:5
Amp = i
a=sim('untitled')
plot(a.simout.time, a.simout.signals.values)
hold on;
end
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!