0
votes

I started to use Simulink and I have a question about changing a transfer function using matlab for loop.

Let say I have the following problem:enter image description here

And my goal is that "system" will be equal to:

enter image description here

Basically I want to run 5 Simulink simulations from time = 0 to time = 10 for 5 different transfer functions.

Any help is appreciated. Thank you.

1
...i is the simulation number, e.g., i = 1:5?Rody Oldenhuis
Do you mean to say that (1 + s*5/i)^i is the closed-loop transfer function or the "system" transfer function for iteration i? Also, I wouldn't use an S-Function, it's unnecessarily complicated for something like that.am304
The equation for your system is non-causal. Are you sure it's correct? (Should the power be -i instead of i?)Phil Goddard

1 Answers

0
votes

Unless I misunderstood your question, I don't think you need to use Simulink for something like this. The following is my understanding of what you're trying to do, it can be done in plain MATLAB (with the control system toolbox):

t = 0:1e-3:10;
u = ones(size(t));
y = zeros(5,length(t));
for k=1:5
    H = (1 + tf('s')*5/k)^k; % system transfer function
    CL = 1/((tf('s'))^2*(1-H)); % closed-loop transfer function
    y(k,:) = (lsim(CL,u,t))';
end
plot(t,y)
legend('#1','#2','#3','#4','#5','Location','NorthWest')
grid on
xlabel('Time [s]')
ylabel('Output')

which produces the following plot (in Octave). Only the first 2 iterations give a non-zero output:

enter image description here