Changing parameters of a block for different simulation steps
1 回表示 (過去 30 日間)
古いコメントを表示
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
0 件のコメント
回答 (1 件)
Stephen
2017 年 10 月 4 日
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
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!