
How to replicate Matlab moving average to Simulink model?
    2 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    Desislava Petkova
 il 6 Feb 2022
  
    
    
    
    
    Commentato: Mathieu NOE
      
 il 7 Feb 2022
            Hi All, i am struggling to figure out how to replicate my Matlab moving average filter results to a simulink model? Pretty new in the Simulink world .... I have tried using the From file block, but this doesn't seem to work. Can someone help guide me in the right derictions, pretty please? 
Matlab code below. 
sample_window_size=30;
total_no_of_expected_data_samples=24*30;
averaging_vector=(1/sample_window_size)*ones(1,sample_window_size)
norm_y=1
lower_limit=50
upper_limit=2000
original_data=lower_limit+rand(1,total_no_of_expected_data_samples).*(upper_limit-lower_limit)
filtered_data=filter(averaging_vector,norm_y,original_data);
t=1:length(original_data)
plot(t,original_data,'--',t,filtered_data,'-')
legend('Original Data','Filtered Data')
0 Commenti
Risposta accettata
  Mathieu NOE
      
 il 7 Feb 2022
        hello 
in terms of signal processing,  a moving average filter is a FIR with all coefficients of the numerator equals ( = 1/n if the FIR numerator length = n , your average length)
use the "discrete filter" block 
NB : you can design any FIR or IIR low pass filter , they will all do your average work with simply different cut off frequency and different slope , so this will both affect the transient and steady state error.
as alternative you can use a "buffer" block followed by the math function "mean"
see example attached 

2 Commenti
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Single-Rate Filters in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


