Clear Filters
Clear Filters

Changing parameters of a block for different simulation steps

1 view (last 30 days)
Hello everybody,
First of all I am working with Simscape but this should not affect the way how to solve the following problem.
Let me explain what I am doing. I made a Simulink model with discrete sample points. The vector with the sample times is called 't' (e.g. t = [0:1:100]). My Simscape model is built with Resistances which are parameterized by a variable called 'R', which is defined in the workspace of matlab.
What I want to do is: I want to change the value of 'R' in dependency of the sample time steps. The way I tried to solve the problem is, I defined a vector 'R' with the same length as the sample time (length® == length(t)). The problem I face is that I need a counting variable 'i', which counts up like i = i + 1 for each simulation step, so I can parameterize the used blocks/resistances with 'R(i)'.
Is there any way to solve this problem or are there other ways to change parameters for each simulation step?
thank you very much,
best regards Timo

Answers (1)

Stephen
Stephen on 4 Oct 2017
A for loop would implement a counting variable as you want, and then you would calculate R(I) in the loop before running the simulation. I suspect that's not the problem and you're trying to do something more, but I can't tell what from your description.
Example: for i = 1:length(t) R(i) = f(i,t) %% where f is whatever function defines the relationship between R, i, and t end

Categories

Find more on Simulink in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!