How to convert a square wave to frequency domain in Matlab or simulink

23 views (last 30 days)
Hi all,
I am so grateful, if you can give me some hints and advice for this issue.
I read a analog signal from my Arduino which is a square wave signal. I would like to obtain the frequency of this signal to do further control work. However, I do not know how to obtain it.
(1) I found some models with FFT function in simulink, but the input signal is DSP sine wave signal in these models. If I replace the input signal (DSP sine wave) with the square wave obtained from Arduino, these models will not work.
(2) If I do it in Matlab rather than Simulink, which fuction is valid in this case? And how can I convert the continuous signal in to frequency domain (or just get the value of the frequency) in Matlab?

Accepted Answer

Shivam Kumar Singh
Shivam Kumar Singh on 5 Jul 2020
You can use fft() function in Matlab.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!