0
$\begingroup$

i have a measured signal (e.g. voltage sine wave) and i would like to generate a sine wave which matches this meausred signal (with the generated sine wave i remove the harmonics from my measured signal), just like a PLL block in simulink.

for that i have to do the 2 steps:

1- Calculate the frequency of the measured signal from detecting the Zerocrossing.

2- calcualte the sine function using sin(2*pi*f(t)*t).

I have the following problem.

1- calcuating the frequency by counting the samples between two zerocrossing would results in getting the frequency at one point so my calcualted fequency does not match my sampled measured signal.

2- even when interpolating or using the repmat function i am able to get the f(t) to be the same length as the time (t) vector yet my sine wave is not correctly calcualted. i know that:

I am adding the zerocrossing times on my time vector which makes the last one inconsistance which mean the sampling rate is changing also.

so how to genereate a sine wave which changing frequency and changing sampling rate of the time signal?

Best Reagrdsenter image description here

$\endgroup$

marked as duplicate by datageist Aug 27 '14 at 9:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

migrated from stackoverflow.com Aug 27 '14 at 8:44

This question came from our site for professional and enthusiast programmers.

  • $\begingroup$ thx for the info. i thought it might also be helpfull to see if someone has an idea here :) $\endgroup$ – user2573266 Aug 13 '14 at 6:48
  • $\begingroup$ Since you've mentioned PLL, it might yield better result if you use phase locking techniques. Set the output frequency as a global, generate the output continuously, calculate the PLL parameters continuously, and adjust the global according to those parameters. $\endgroup$ – Yvon Aug 14 '14 at 4:33
  • $\begingroup$ @Yvon do you have an m.file that can do those steps. i don't want to re-do stuff that is already been done :) $\endgroup$ – user2573266 Aug 14 '14 at 13:24
  • $\begingroup$ How about these ones? mathworks.com/mixed-signal-systems/mixed-signal-analysis.html and mathworks.com/company/newsletters/articles/… Note that I do not own these works :) $\endgroup$ – Yvon Aug 14 '14 at 16:58

Browse other questions tagged or ask your own question.