# Is it possible to change the Resistor in Simulation at a particular time point?

**URL:** <https://forum.plexim.com/t/is-it-possible-to-change-the-resistor-in-simulation-at-a-particular-time-point/1016>\
**Category:** PLECS\
**Tags:** plecs, script\
**Created:** [May 2, 2021, 9:32am UTC](https://forum.plexim.com/t/is-it-possible-to-change-the-resistor-in-simulation-at-a-particular-time-point/1016 "2021-05-02T09:32:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![fish\_94](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@fish\_94](https://forum.plexim.com/u/fish_94)\
**Post date:** [May 2, 2021, 9:32am UTC](https://forum.plexim.com/t/is-it-possible-to-change-the-resistor-in-simulation-at-a-particular-time-point/1016/1 "2021-05-02T09:32:18Z")

</div>

Hello everyone,

I have a question about the Simulation in PLECS.

I have built a circuit model in PLECS and I want to change the value of resistor in Simulation at a particular time point.

For example:

00.2 R3=50; (t=time)

I have tried to write it in Simulation script, but I don’t know how to describe the time.

I am so confused about it. It’s appreciated if you could help me solve the problem. Thanks a lot!

 ![circuit.png](https://europe1.discourse-cdn.com/flex006/uploads/plecs/original/1X/6d09681bfe8ab77e80a3b0bd8be909c63c88787a.png)

---

<div class="post-metadata">

**Author:** ![Oliver\_Schwartz](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/oliver_schwartz/32/6_2.png) [@Oliver\_Schwartz](https://forum.plexim.com/u/Oliver_Schwartz)\
**Post date:** [May 3, 2021, 4:25am UTC](https://forum.plexim.com/t/is-it-possible-to-change-the-resistor-in-simulation-at-a-particular-time-point/1016/2 "2021-05-03T04:25:23Z")

</div>

You cannot easily change the resistor value in a running simulation.

The usual approach is to use a second resistor in parallel or series to the first resistor and use a switch to connect / disconnect it. The switch can be triggered by a step function, for example.

---

<div class="post-metadata">

**Author:** ![siderlee](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@siderlee](https://forum.plexim.com/u/siderlee)\
**Post date:** [July 8, 2025, 3:07am UTC](https://forum.plexim.com/t/is-it-possible-to-change-the-resistor-in-simulation-at-a-particular-time-point/1016/3 "2025-07-08T03:07:26Z")

</div>

this value can be stepped?

---

<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 8, 2025, 2:48pm UTC](https://forum.plexim.com/t/is-it-possible-to-change-the-resistor-in-simulation-at-a-particular-time-point/1016/4 "2025-07-08T14:48:57Z")

</div>

You can model a step change in load using the approach Oliver described above.

I’ll add that there are variable resistance components in the PLECS library. The “Variable Resistor” component introduces an algebraic loop in the simulation, which I would recommend avoiding. However, the “Variable Resistor with Constant Capacitor” and “Variable Resistor with Constant Inductor” components do not introduce algebraic loops because the terminal conditions of the resistor are defined by the capacitor voltage or inductor current.

You can also “step” the resistance values using a simulation script if you want to analyze a range of loading scenarios (akin to the .STEP SPICE macro). See the “Buck Converter with Parameter Sweep” demo model for an example.

---

<div class="post-metadata">

**Author:** ![siderlee](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@siderlee](https://forum.plexim.com/u/siderlee)\
**Post date:** [July 9, 2025, 1:44am UTC](https://forum.plexim.com/t/is-it-possible-to-change-the-resistor-in-simulation-at-a-particular-time-point/1016/5 "2025-07-09T01:44:48Z")

</div>

Hi, Bryan, thank you for your reply.  
I will try.

---

<div class="post-metadata">

**Author:** ![siderlee](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@siderlee](https://forum.plexim.com/u/siderlee)\
**Post date:** [July 10, 2025, 6:40am UTC](https://forum.plexim.com/t/is-it-possible-to-change-the-resistor-in-simulation-at-a-particular-time-point/1016/6 "2025-07-10T06:40:18Z")

</div>

![image](https://europe1.discourse-cdn.com/flex006/uploads/plecs/original/2X/e/eb423f784d19241a02aa95529f8f0a83e82c2ce4.png)  
I find than you can use the initialization to simulate a parameter with an array.

such as, R=[1,2,3,4,5]

if you want change the value which involve simulation time, maybe you need a FUNCTION BLCOK clock’, and then setup an function which parameters is a function of time.

---

<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 14, 2025, 4:00pm UTC](https://forum.plexim.com/t/is-it-possible-to-change-the-resistor-in-simulation-at-a-particular-time-point/1016/7 "2025-07-14T16:00:34Z")

</div>

Yes, that is a good point. You can also use 1D look-up tables for the same purpose, just be cognizant of interpolation/extrapolation behavior in between the defined sample points. By default the data will be interpolated, but you can have zero-order hold like behavior by repeating datapoints. An example script is below, where timeVector and outputVector are the X and Y vectors for a 1D look-up table.

```auto
time = [1,2,3];
values = [600e-9,1e-6,2e-6];
interpolationBehavior = 1; % 1= linear, 2=zoh/stepwise.

if interpolationBehavior==1 % Linear interpolation
	timeVector = time;
	outputVector = values;
else % stepwise
	timeVector = [repelem(time,1,2)(2:end),time(end)];
	outputVector = repelem(values,1,2)(1:end);
end

```
