Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Harinee Kannan
Harinee Kannan le 28 Mar 2017
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

Réponse acceptée

dbmn
dbmn le 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 commentaire
Harinee Kannan
Harinee Kannan le 11 Avr 2017
Modifié(e) : Harinee Kannan le 11 Avr 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?

Connectez-vous pour commenter.

Plus de réponses (1)

ES
ES le 28 Mar 2017
Modifié(e) : ES le 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

Community Treasure Hunt

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

Start Hunting!

Translated by