# How to linearly vary the amplitude and frequency in a 3 phase voltage source block with time?

16 views (last 30 days)
Muhammad Aqeel on 13 May 2024
Answered: Muhammad Aqeel on 27 May 2024 at 10:43
I am working with the 'Three-Phase Programmable Voltage Source' block in simulink and I want to linearly vary both amplitude and frequency of the source with respect to simulation time. The exact functions I want are something like:
Amplitude = 5.5 + 10*t Volts (for 0<t<10) and 105.5 (for t>10)
Frequency = 5 + 8*t Hertz (for 0<t<10) and 85 (for t>10)
Where t is simulation time in seconds
How should I go about doing this? I am a novice so any help is appreciated.
##### 0 CommentsShow -2 older commentsHide -2 older comments

Sign in to comment.

### Accepted Answer

Shubham on 25 May 2024 at 9:10
Hey Muhammad,
You can try using custom functions as per your need. For example, the following images show that you can parameterize the PID controller block for programmatically setting parameter values:
For more information about setting block paramter values, refer to the following documentation:
You can also retrieve the current simulation time and incorporate in your functions to modify the parameter values as desired. For this purpose, you may find the following MATLAB Answer helpful: https://www.mathworks.com/matlabcentral/answers/57825-how-to-get-current-time-of-simulation-while-model-is-executing
Once you have obtained the simulation time, you can update your parameter value by using the custom function.
You may also find the following useful:
Just putting it out there that you can create custom blocks as well:
I hope this helps!
##### 1 CommentShow -1 older commentsHide -1 older comments
Muhammad Aqeel on 27 May 2024 at 10:14
Thanks for the help! Much appreciated.

Sign in to comment.

### More Answers (1)

Muhammad Aqeel on 27 May 2024 at 10:43
While Shubham's answer works for all cases where you might need to control parameters with respect to time, I had found another method that works only for voltage sources whose parameters vary with respect to time. I wanted to put this out in case anyone may find it useful.
The idea is to use a matlab function that generates the custom variation of amplitude and frequency wrt time. Then, you use a controlled voltage source block to convert this variation into a voltage. This is what it looks like:
Essentially, you make your own 3 phase source instead of using matlab's inbuilt 3 phase voltage sources. The code for the matlab function looks like:
The result is 3 voltages which follow the desired variation. This approach should work for current sources as well. Hope you find this helpful!
##### 0 CommentsShow -2 older commentsHide -2 older comments

Sign in to comment.

### Categories

Find more on Electrical Block Libraries in Help Center and File Exchange

R2020a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!