フィルターのクリア

How can i get required number of sample from simulink to workspace?

1 回表示 (過去 30 日間)
Harinee Kannan
Harinee Kannan 2017 年 3 月 28 日
編集済み: Harinee Kannan 2017 年 4 月 11 日
I have a synchronous generator model and it runs for an interval 0 to 50 sec.Finally i get current output in three phase and the size of my current values passed is 1000001x1 but i can use only 1001x1 values for further calculation. How can i reduce the size from 1000001x1 to 1001x1 without any distortion in the current values

採用された回答

dbmn
dbmn 2017 年 3 月 28 日
There are multiple possible solutions to your question (with different results), but all of them will fail the "without any distortion" requirement.
  • you can just take every 1000th element (bad if there is high frequency noise)
new_var = sim_var(1:1000:end);
  • do the same, but with a filter first (f.ex. moving average) - better for noise
% create moving average
sim_var2 = movmean(sim_var,1000);
% same as before
new_var2 = sim_var2(1:1000:end);
attached is a little example to show your the differences between the first two approaches
  • Interpolate the values in your postprocessing calculation using "interp1"
  • choose a different Stepsize for Simulation (100001 sounds like fixed step) to get to 1001 points
  1 件のコメント
Harinee Kannan
Harinee Kannan 2017 年 4 月 11 日
編集済み: Harinee Kannan 2017 年 4 月 11 日
The method was useful but there is a heavy loss in data. Now am trying to make the process online so as the values from simulink comes out, I can process it without storing. Is there any procedure to make the simulation online?

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

その他の回答 (1 件)

ES
ES 2017 年 3 月 28 日
編集済み: ES 2017 年 3 月 28 日
Resample the data.
For example,
>> a = zeros(1000001,1); % Some data
>> b = a(1:1000:end); % Take every 1000th data
>> size(b)
ans =
1001 1

Community Treasure Hunt

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

Start Hunting!

Translated by