If you build your power electronic model in Matlab/Simulink then you can calculate your current and voltage waveforms. One you get these waveforms use the tool box of the fast Fourier transform to resolve the waveform into its fundamental and harmonics sinusoids provided that you have to sample the waveform with a sampling frequency greater than 2 times the highest possible harmonic frequency.
You can also measure the waveform of any experimental circuit and acquire it by using data acquisition cards then store the waveforms and analyze them using the FFT tool box.
At the first, The Fourier transform is a mathematical formula that relates a signal sampled in time or space to the same signal sampled in frequency. In signal processing, the Fourier transform can reveal important characteristics of a signal, namely, its frequency components.
There are many tools and techniques in MATLAB about your topic for example, but not limited:
You can benefit from this tool in MATLAB Simulink:
PS Harmonic Estimator (Amplitude, Phase), which help you to: Measure harmonic amplitude and phase of periodic signal.
The PS Harmonic Estimator (Amplitude, Phase) block measures amplitude and phase of a single frequency component (harmonic) of a periodic signal.
A signal is periodic if it completes a pattern within a measurable time frame, called a period, and repeats that pattern over identical subsequent periods. The signal base frequency is the number of periods per second.
The block accepts a physical signal with one or more harmonics present. It outputs the phase and amplitude for the selected harmonic. Untyped physical ports facilitate unit propagation. The output signal for the amplitude has the same physical unit as the input signal. The output signal for phase has the unit of radians, or 1. For more information, see Angular Units.
To obtain meaningful results, run the simulation for at least one full time period of the signal.
the example (@https://www.mathworks.com/help/dsp/ug/spectrum-analyzer-measurements.html) shows how to perform measurements using the Spectrum Analyzer block. The example contains a typical setup to perform harmonic distortion measurements (THD, SNR, SINAD, SFDR), third-order intermodulation distortion measurements (TOI), and adjacent channel power ratio measurements (ACPR). The example also shows how to view time-varying spectra by using a spectrogram and automatic peak detection.
Several measurements and their corresponding setups are contained in the example model.
And you can benefit from attached valuable Matlab code for harmonic measurement. It will display harmonic spectrum. Measure true value and fundamental.
If the sampling time and other parameters of the Harmonic Measurements Toolboxes are set accurately for both MATLAB\Simulink and PLECS, the obtained results will be almost identical. Personally, I prefer to use PLECS for this purpose.