How to plot the mean of a sinusoidal function

조회 수: 18 (최근 30일)
João Oliveira
João Oliveira 2014년 4월 22일
댓글: João Oliveira 2014년 5월 14일
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,

답변 (3개)

Graham Fletcher
Graham Fletcher 2014년 4월 22일
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.

João Oliveira
João Oliveira 2014년 4월 23일
Thanks Graham but isn't there any built in block on simulink that provide this type of output?

João Oliveira
João Oliveira 2014년 5월 12일
It is possible to use the block Discrete FIR Filter to get the moving average result? It seems this block is the replace of "Weighted Moving Average (Obsolete)" block but I cant get the desired output...
  댓글 수: 2
Honglei Chen
Honglei Chen 2014년 5월 12일
That should work, just use
1/N*ones(1,N)
in the Coefficient parameter, where N is the window length
João Oliveira
João Oliveira 2014년 5월 14일
Hi Honglei, it didn't work.
Hi get the result in the image bellow. Can you tell me what the meaning of the expression 1/N*ones(1,N) ? I put that on the "Numerator coefficients:" parameters with N =120 (my simulation time).

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Signal Attributes and Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by