フィルターのクリア

Build or update data set in a data object with for loop

1 回表示 (過去 30 日間)
Yves
Yves 2018 年 5 月 4 日
コメント済み: Yves 2018 年 5 月 4 日
Would like your advice on designing my coding structure (architecting). I am trying to simulate a state-space modeled control loop in Matlab (not Simulink). I would like all my signals in the loop to be data objects, with the physical signal being the primary property. It seems to me, in order to simulate the dynamic response of the loop, a for loop must be used to compute the local response one data point at a time, which would mean my primary property of each data object is computed one at a time. Can I do it this way, with ip being the input data object, ip.signal the dataset?
for i = 1:length(ip.signal)
x(i+1) = A.*x(i) + B.*ip.signal(i);
op.signal(i) = C.*x(i) + D.*ip.signal(i);
end
The property "signal" of output data object op is constructed point by point like that, yes or no? Or you have a more elegant way of doing it?
  2 件のコメント
sloppydisk
sloppydisk 2018 年 5 月 4 日
This should work fine, just make sure to preallocate your output signal and x signal before the loop. I also think you might want to add x to your output signal object, since it is also a state variable, right?
Yves
Yves 2018 年 5 月 4 日
Thanks, Jasper. Yes, I should; x is a state variable.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeScopes and Data Logging についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by