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

3 views (last 30 days)
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

Accepted Answer

dbmn
dbmn on 28 Mar 2017
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 Comment
Harinee Kannan
Harinee Kannan on 11 Apr 2017
Edited: Harinee Kannan on 11 Apr 2017
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?

Sign in to comment.

More Answers (1)

ES
ES on 28 Mar 2017
Edited: ES on 28 Mar 2017
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

Categories

Find more on Filter Design and Analysis in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!