# How to do Feedback Loop on Simulink with different frequinces

2 views (last 30 days)
Esin Derin on 23 Jun 2022
Commented: Paul on 24 Jun 2022
Hello, I'm trying to build a Simulink for a open and closed loop. I have to put harmonic input signal (instead of step) with amplitude 3. Input the signal into closed and open system. And found the amplitude of the output signal for both systems. Then I have to change the signal frequency 0.1 Hz to 100 Hz with increasing step ( 0.1Hz, 0.2 Hz, 0.4 Hz .... )
Attached here, you can find my diagram.

Sam Chak on 24 Jun 2022
Edited: Sam Chak on 24 Jun 2022
First, you need to construct the frequency {0.1, 0.2, 0.4, 0.8, 1.6, ...} based on the following sequence that depends on the integer variable , which is constructed using a summation of Step functions. Note that mathematically, the sequence won't arrive exactly at 100 Hz, but 102.4 Hz. Next, construct the Input Sine wave with varying sequential frequency. The overall system looks like this. The step times of the 11 Step function blocks are implied in the Block names. Then, run the simulation and plot the outputs. Esin Derin on 24 Jun 2022
Thank you:)

Paul on 24 Jun 2022
I'm assuming the question is how to run the same simulation multiple times for different frequencies. With this assumption ....
1. Replace the block labeled Sine Wave Function with the Sine Wave block
2. Double click the Sine Wave block, set the Amplitude parameter to 3, set the Frequency parameter to: freqHz*2*pi (enter it exactly that way).
3. In the Matlab workspace, or in a script, implement
freqvec = [0.1 0.2 0.4]; % choose whatever frequencies are needed
for ii = 1:numel(freqvec)
freqHz = freqvec(ii);
out = sim('Esin'); % use the actual name of the .slx file
% do whatever processing is needed on out
end
Depending on what you're actually doing, the model and/or the code above might have to be modified, but this should be enough to give the basic idea.
I believe there is also a doc page that explains alternatives methods for running multiple simulations for a parameter sweep.
##### 2 CommentsShowHide 1 older comment
Paul on 24 Jun 2022
I missed a step:
Add two To Workspace blocks and connect them to the same signals that are feeding the scopes.