I'm new to Matlab/Simulink and would like to convert the continuous system below to discrete for eventual conversion to C code. Matlab has a c2d function, but I don't know how to apply it to a simulink system. The c2d function requires the system to be in transfer function or state-space form, neither of which I know how to convert the diagram to.

So any ideas on how to use the c2d function in this situation? Or should I use something like Tick's rule to replace the integrators? Any other methods?

Here is the simulink diagram in question. It's purpose is to determine the fundamental of a sine wave. With further stages, it can also extract higher harmonics if present. The scope is connected to the fundamental frequency estimate. The system needs to be converted to 44.1Khz sampled system.

enter image description here

See this paper for more info: http://ijcsi.org/papers/IJCSI-8-5-1-360-365.pdf

  • 1
    $\begingroup$ Assuming that your source is the sine signal and is being sampled in real life, you could simply change the sine signal to a sampled sine signal having impulses at sampling frequency. $\endgroup$
    – Naresh
    May 2, 2013 at 8:21
  • $\begingroup$ Wouldn't I also have to change the integrators to a sampled integrator? Maybe it is this simple after all, and C2D is not needed or appropriate. $\endgroup$ May 2, 2013 at 13:02
  • $\begingroup$ Yes. Change the integrators to a sampled integrator as well. $\endgroup$
    – Naresh
    May 2, 2013 at 15:07
  • $\begingroup$ I was able to convert to discrete by changing the sine wave generator and the integrators to discrete versions, and also choosing a discrete solver ode3. Got very similar results to the paper. $\endgroup$ May 4, 2013 at 4:52


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.