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

fast fourier transformfftfrequency domainsignal processingsquare wave

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?

Best Answer

You can use fft() function in Matlab.
Related Question