How to plot the mean of a sinusoidal function
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
Like the image below I want to use a block from simulink which allow me to plot the mean value (green line) of a sinusoidal function (blue line). I've tried the block "mean value (linear)" but it just gave me another sinusoidal function with less amplitude compared to the original. Can someone tell me which block should I use?
Regards,
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/161489/image.png)
0 commentaires
Réponses (3)
Graham Fletcher
le 22 Avr 2014
Hi João,
My solution would probably be to create an integrator (ie. sinusoid value into a sum together with previous value of the sum output) and a counter which increments by 1 each sample, and divide the integrator by the counter. This would give you a mean according to the definition mean = sum(samples) / num samples. Its not too efficient so I'd probably rethink if that was a concern but I think it'd work for what you describe.
HTH, G.
0 commentaires
João Oliveira
le 12 Mai 2014
2 commentaires
Honglei Chen
le 12 Mai 2014
That should work, just use
1/N*ones(1,N)
in the Coefficient parameter, where N is the window length
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!