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

1 次查看(过去 30 天)
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