hey guys, i need help to save the peak values of my FFT waveform. Is there a function i can use??

hey guys, Im doing an fft on a nonsinusoidal waveform, my FFt graph has a fundamental and harmonics. I would like to save the magnitude values of the fundamental and the harmonics plus thier corresponding frequencies. I tried the find peak function but that gave me all the peaks including the noise values. I only want the fundamental and the harmonic components. Can anyone help me? I will attach a picture of my FFt waveform

Answers (1)

The findpeaks function will do everything you asked. It has a number of name-value pair arguments such as 'MinPeakHeight' and 'MinPeakDistance' that will constrain the results it returns. (These have been expanded in recent releases, so earlier versions may not have all of them.)

4 Comments

ok guys so i used the functions and i sure the variables using disp(pks). so im currently trying to save these variables by using the to workspace function and i got this error. Data 'pks' is inferred as a variable size matrix, while its specified type is something else. can anyone tell me how to fix this
I don’t understand. The output of findpeaks already exist in your workspace as the variable names you assigned to them in the findpeaks call.
If you want to save them to a file (a good idea), the easiest way is to just use the save function to save them to a .mat file. You can then load them back into your workspace as you need them without having to re-run your present code.
The "workspace function" displays the workspace panel in the MATLAB development environment so you can see your variables. It is not used for saving variables to the workspace. The variables are already in the workspace immediately after calling findpeaks().
The save() function is used to save those variables to a disk file, in case you want to do that.
We have no idea what threw the error you mentioned. Please copy ALL THE RED TEXT and paste it back here so we can see the actual code and the actual error message.
I’m fairly certain Olando is referring to the To Workspace block. There are a number of options for it.
I’ve not used Simulink in a while, and I’ve not used that particular sink, so since we’re lacking in other details as well, we can only guess.

Sign in to comment.

Asked:

on 28 Jan 2016

Commented:

on 28 Jan 2016

Community Treasure Hunt

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

Start Hunting!