# Plecs('simulate') command doesn't work in MATLAB

**URL:** <https://forum.plexim.com/t/plecs-simulate-command-doesnt-work-in-matlab/871>\
**Category:** PLECS\
**Tags:** matlab, plecs-blockset, supported-matlab-commands\
**Created:** [October 2, 2020, 1:07am UTC](https://forum.plexim.com/t/plecs-simulate-command-doesnt-work-in-matlab/871 "2020-10-02T01:07:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![flin036](https://avatars.discourse-cdn.com/v4/letter/f/a9adbd/32.png) [@flin036](https://forum.plexim.com/u/flin036)\
**Post date:** [October 2, 2020, 1:07am UTC](https://forum.plexim.com/t/plecs-simulate-command-doesnt-work-in-matlab/871/1 "2020-10-02T01:07:50Z")

</div>

Hi

I am trying to automate a series of simulation with variable components. I have MATLAB R1029b and Plecs 4.3.6. I am trying to run the example shown in

> **[Simulation Scripting with PLECS Standalone | Plexim](https://www.plexim.com/support/videos/simulation-scripting-standalone)**

When the script runs to plecs(‘simulate’, varStructure); i get the following error:

USAGE: PLECS(‘CMD’,‘PARAMETER1’,‘PARAMETER2’,…)  
Known commands are: get, set, version, hostid, export, thermal, scope, checkout

Is this an issue with my Plecs version? Other commands such as ‘get’ ‘set’ and ‘scope’ all work.

---

<div class="post-metadata">

**Author:** ![Kris\_Eberle](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/kris_eberle/32/6_2.png) [@Kris\_Eberle](https://forum.plexim.com/u/Kris_Eberle)\
**Post date:** [October 2, 2020, 1:27am UTC](https://forum.plexim.com/t/plecs-simulate-command-doesnt-work-in-matlab/871/2 "2020-10-02T01:27:05Z")

</div>

Can you post the model or the full script code here?

---

<div class="post-metadata">

**Author:** ![flin036](https://avatars.discourse-cdn.com/v4/letter/f/a9adbd/32.png) [@flin036](https://forum.plexim.com/u/flin036)\
**Post date:** [October 4, 2020, 5:23pm UTC](https://forum.plexim.com/t/plecs-simulate-command-doesnt-work-in-matlab/871/3 "2020-10-04T17:23:55Z")

</div>

Hi Kris

The block of code I use is:

mdl = plecs(‘get’,‘’,‘CurrentCircuit’);  
%plecs(‘simulate’);  
sim([‘MATT\_PADS\_TEST’],30e-3);  
plecs(‘scope’,[mdl ‘/Scope1’] ,‘HoldTrace’, [‘kmin’]);  
data\_kmin = plecs(‘scope’,[mdl ‘/Scope1’] ,‘GetCursorData’, [0.018952941176470374 0.018964705882352727],‘rms’);

Note here since I am running plecs blockset I can use simulink to run the simulation, but I cannot use the plecs(‘simulate’) command (hence it is commented out).

All the other plecs commands involving scope and getting and setting component values in plecs works.

I would like to use the plecs(‘simulate’) command as it provides a better way of performing a component sweep without having to write a for loop.

Thank you for your help

---

<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:** [October 5, 2020, 3:51pm UTC](https://forum.plexim.com/t/plecs-simulate-command-doesnt-work-in-matlab/871/4 "2020-10-05T15:51:40Z")

</div>

Since you’re using PLECS Blockset, Simulink handles the actual execution of the model, not PLECS. You would use the [sim(‘model’)](https://www.mathworks.com/help/simulink/slref/sim.html) call, as you have pointed out already. The video you are referencing is for PLECS Standalone, where PLECS handles the execution of the model, and therefore has a different command to run the model.You can still access the PLECS model, manipulate parameters, save scope captures, and so on through the PLECS API, and intermix these calls with MATLAB calls as needed.

Refer to the “Buck Converter with Parameter Sweep” demo model. It highlights the code used to run a parameter sweep for PLECS Blockset and Standalone.
