Simulink To workspace issues R2017a

In my simulink model (svpwm_inverter_rlc_A)
I have a 6 input mux block whose output connects to a "To workspace" block i named "currvolt".
When i run my code, (The relevant segment is shown below):
**************************************************
% Although 5 periods used, plot for 6 periods to show input turnoff transients
mysimstop = num2str(6/(1e3*f2usekhz));
% Run the simulink mode
sim('svpwm_inverter_rlc_A','StopTime', mysimstop)
%sim('svpwm_inverter_rlc_A')
t = currvolt.time;
currA = currvolt.signals.values(:,1); % 1st variable is 1st column of values
voltA = currvolt.signals.values(:,2); % 2nd variable is 2nd column of values
currB = currvolt.signals.values(:,3);
voltB = currvolt.signals.values(:,4);
currC = currvolt.signals.values(:,5);
voltC = currvolt.signals.values(:,6);
********************************************
I do not get the "currvolt" structure in the Matlab workspace.
However when i replace "sim('svpwm_inverter_rlc_A','StopTime', mysimstop)" with
" sim('svpwm_inverter_rlc_A')" ,
i get the "currvolt" output in the Matlab workspace
Are there other options i need to include in my Matlab configuration?
Thanks
David

 Respuesta aceptada

Paul
Paul el 12 de Nov. de 2021
Editada: Paul el 12 de Nov. de 2021
Don't know why those two sim commands would yield different results. In the first instance, I suspect that currvolt is inside ans, which is the output of the sim command, assuming you checked the box in
Simulation -> Model Configuraton Paramters -> Data Import/Export -> Single Simulation Output
Try
simdata = sim(...)
and see if currvolt shows up in simdata for both uses.

3 comentarios

David
David el 13 de Nov. de 2021
The checkbox "Simulation -> Model Configuraton Paramters -> Data Import/Export -> Single Simulation Output" is not checked.
when i tried your suggestion, it worked for
simdata = sim('svpwm_inverter_rlc_A','StopTime', mysimstop)
%simdata = sim('svpwm_inverter_rlc_A')
t = simdata.currvolt.time;
currA = simdata.currvolt.signals.values(:,1); % 1st variable is 1st column of values
voltA = simdata.currvolt.signals.values(:,2); % 2nd variable is 2nd column of values
currB = simdata.currvolt.signals.values(:,3);
voltB = simdata.currvolt.signals.values(:,4);
currC = simdata.currvolt.signals.values(:,5);
voltC = simdata.currvolt.signals.values(:,6);
However when i use "simdata = sim('svpwm_inverter_rlc_A')" instead of " simdata = sim('svpwm_inverter_rlc_A','StopTime', mysimstop) "
simdata is a 40651x1 double array which is simply the simulation time instances so i do not have access to currvolt.
Anyway. Thanks for your suggestion since i want to include the 'StopTime' parameter
simdata = sim('svpwm_inverter_rlc_A','StopTime', mysimstop)
works for me.
Paul
Paul el 13 de Nov. de 2021
That's interesting. It sounds like the command
simdata = sim('svpwm_inverter_rlc_A')
is returning the time vector as the first output of the "backward compatible syntax" while
simdata = sim('svpwm_inverter_rlc_A','StopTime', mysimstop)
is using the single output. That's not how it's supposed to work according to the doc, at least as I read it.
I wonder if both commands would yield the same type of output if you check the box on Single Simulation Output.
David
David el 15 de Nov. de 2021
This worked. After checking the "Single Simulation Output" and inserting the name "currvolt".
Thanks a lot.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Simulink Environment Customization en Centro de ayuda y File Exchange.

Productos

Versión

R2017a

Preguntada:

el 12 de Nov. de 2021

Comentada:

el 15 de Nov. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by