Implementing a step response within for loop environment?

3 ビュー (過去 30 日間)
Juan Heredia
Juan Heredia 2017 年 10 月 24 日
回答済み: Kuifeng 2017 年 10 月 25 日
  • I'm currently working on a model that is being implemented in a for-loop environment (I know the feedback() function exists but I need to look at the signals as they loopback, and change parameters mid-loop).
  • In theory, a section of the model creates a step signal that goes into a simple transfer function and continues to the rest of the model. But I'm having a hard time applying the transfer function, essentially on a per index basis.
I'm wondering if any of you have any tips or suggestions on how to proceed with this implementation. As an example, this is what the pseudo-code would look like for a sample of the model:
time = linspace(0,100,500);
for i = 1:length(time)
sig(i) = sin(2*pi*4e6*time(i) + Phase(i-1) );
% More code that uses sine wave to generate a step-like signal every now and then
% Would usually use 'lsim' to apply tf's, but doesn't work on a per-index basis in this case
StepResp(i) = tf * unitStep(i);
% More calculations
Phase(i) = .....;
end
Thank you in advance,
JH

回答 (1 件)

Kuifeng
Kuifeng 2017 年 10 月 25 日
How about trying to introduce heaviside(x) function in the sig calculation? If certain condition is met, then apply the additional step value.

カテゴリ

Help Center および File ExchangeTime and Frequency Domain Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by