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

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

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.

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

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

Since you’re using PLECS Blockset, Simulink handles the actual execution of the model, not PLECS. You would use the sim(‘model’) 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.