Transfer the code in matlab to plecs

> “The modulator by itself will not work (e.g. setting the input to the gain block to 0.001 results in an error).” ?

Removing the C-Script and testing the model with just the modulator at a fixed duty cycle fails due shorting the output capacitor. This is because of the modulator implementation. See below. You should resolve this first before looking into the C-Script.

> I’m confused the that what’s the majorstep and minorstep?

The “Model Execution” section of the “How PLECS Works” section of the help describes major and minor time steps in detail. The C-Script documentation also provides this helpful guidance: "In general, output signals should be continuous and smooth during minor time steps; discontinuities or sharp bends should only occur during major time steps. Whether or not the call is made for a major time step can be inquired with the IsMajorStep macro. "