# Sim command produces error

**URL:** <https://forum.plexim.com/t/sim-command-produces-error/1136>\
**Category:** PLECS\
**Tags:** plecs, script, plecs-blockset, sim\
**Created:** [July 5, 2022, 4:05pm UTC](https://forum.plexim.com/t/sim-command-produces-error/1136 "2022-07-05T16:05:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alberto\_Sanchez](https://avatars.discourse-cdn.com/v4/letter/a/54ee81/32.png) [@Alberto\_Sanchez](https://forum.plexim.com/u/Alberto_Sanchez)\
**Post date:** [July 5, 2022, 4:05pm UTC](https://forum.plexim.com/t/sim-command-produces-error/1136/1 "2022-07-05T16:05:57Z")

</div>

Hi

I am trying to run a model using PLECS blockset using the sim command in a script. The model runs just fine by pressing the run button, but when I try to use sim I get the following error:

Warning: “Cannot execute method ‘set’ on ‘dos\_plecs/Circuit’ while simulation is running”

My script is the following

%  
% Model initialization  
%  
fs=20e3; % Bridge/Controller switching/sampling frequency  
Ts=1/fs; % Bridge/Controller switching/sampling period

L2=1e-6; % Transformer leakage inductance  
N=8; % Transformer turns ratio  
C3=15e-6; % Bridge bias capacitor

L1=200e-6; % Rectifier filter inductance  
C2=10e-6; % Rectifier filter capacitor  
R1=20; % Load

% PLECS model parameters update  
plecs(‘set’, ‘dos\_plecs/Circuit/L2’, ‘L’, ‘L2’);  
plecs(‘set’, ‘dos\_plecs/Circuit/C3’, ‘C’, ‘C3’);  
plecs(‘set’, ‘dos\_plecs/Circuit/Tr2’, ‘n’, ‘[1 N]’);  
plecs(‘set’, ‘dos\_plecs/Circuit/L1’, ‘L’, ‘L1’);  
plecs(‘set’, ‘dos\_plecs/Circuit/C2’, ‘C’, ‘C2’);  
plecs(‘set’, ‘dos\_plecs/Circuit/R1’, ‘R’, ‘R1’);

%  
% Model simulation  
%  
mdl = plecs(‘get’,‘’,‘CurrentCircuit’)  
sim(‘dos\_plecs’);

 ![Captura.PNG](https://europe1.discourse-cdn.com/flex006/uploads/plecs/original/1X/11396d2efd654a8af516365427115879a708c16b.png)

---

<div class="post-metadata">

**Author:** ![Bryan\_Lieblick](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/bryan_lieblick/32/10_2.png) [@Bryan\_Lieblick](https://forum.plexim.com/u/Bryan_Lieblick)\
**Post date:** [July 5, 2022, 4:41pm UTC](https://forum.plexim.com/t/sim-command-produces-error/1136/2 "2022-07-05T16:41:58Z")

</div>

Alberto, can you please send you model to [support@plexim.com](mailto:support@plexim.com)? Please include version information for both MATLAB and PLECS.
