Simulink outputs variables but they are not being sent to the workspace.

351 vues (au cours des 30 derniers jours)
While using my PC at home I am using 'to workspace' blocks in my diagram with save format array. When I run the simulation i get the following the the command window:
ans =
Simulink.SimulationOutput:
Vin: [2002x1 double]
Vout: [2002x1 double]
t: [2002x1 double]
tout: [2002x1 double]
SimulationMetadata: [1x1 Simulink.SimulationMetadata]
ErrorMessage: [0x0 char]
Undefined function or variable 't'.
Error in P1_2 (line 79)
plot(t,Vin,t,Vout)
It seems to me that simulink is outputting the variables but they are not appearing in the workspace and therefore it thinks they are undefined. I tried running the simulation on a computer at my university and it worked. I tried reinstalling Matlab on my home PC and it still doesnt work. Version 2019.

Réponse acceptée

David Avila
David Avila le 21 Déc 2019
Modifié(e) : David Avila le 21 Déc 2019
If you are running 2019a, the Simulink default settings for the "To Workspace" block have been changed and would need to be set back from being a single simulation output:
I have to do this every time I make a new model till further notice
Edit: Grammar
  26 commentaires
Khaled Hassan
Khaled Hassan le 22 Jan 2023
Thank you very much, I was loosing my mind. This was very helpful
Elmer
Elmer le 20 Mai 2023
Muchas gracias...

Connectez-vous pour commenter.

Plus de réponses (2)

Rostislav Teryaev
Rostislav Teryaev le 2 Avr 2019
First of all, you have to assign a structure Simulink.SimulationOutput to some variable
temp = Simulink.SimulationOutput;
Next, you need to access field t or Vin of this structure
temp.t
temp.Vin
To use plot you want this
temp = Simulink.SimulationOutput;
plot(temp.t, temp.Vin, temp.t, temp.Vout)

mete teke
mete teke le 7 Déc 2022
Thank a lot...

Catégories

En savoir plus sur Simulink dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by