Firstly, I apologize if this may seem like a very basic question but I'm just beginning to learn Matlab and I've encountered a problem that I couldn't seem to find the solution to online.
I performed the fft of a signal and plotted the graph of amplitude vs frequency. I also used a Savitsky Golay filter to smoothen the plot so it would be easier.
My problem is, I want to find the X and Y co-ordinates of the largest peak and store the data in a variable. The location of the peak is shown in the figure that is attached. I tried to find a way doing it with the findpeaks() function but did not succeed. I may have been using it wrong though.
I've also added the code of what I could manage to do so far.
num = xlsread('C:\UTwente\Q4\Structural Health and Condition monitoring\Case Roadbridge (Zwartewaterbrug)\00001 Cars 03-23-17 09.29.07 AM.xlsx','Measurement data');
sig = num(:,16);
sig = sig - mean(sig); % Remove d-c Offset
L = length(sig);
Fs = 1000; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
FTsig = fft(sig)/L;
Fv = linspace(0, 1, fix(length(FTsig)/2)+1)*Fn; % Frequency Vector
Iv = 1:length(Fv); % Index Vector
FTsiga = double(abs(FTsig(Iv))*2); % Truncate, Magnitude, Convert To Double
sgf_sm = sgolayfilt(FTsiga, 5, 501); % Create ‘sgolayfilt’ Filtered FFT
figure(1)
plot(Fv, FTsiga)
hold on
plot(Fv, sgf_sm, '-r', 'LineWidth',2)
hold off
grid
xlabel('Frequency')
ylabel('Amplitude')
legend('Original Spectrum', 'Smoothed & Filtered Spectrum')
[Ymax,ind] = max(y)
and thenXmax = x(ind)
– obchardon