我认为您无法正确构建频率轴。一旦你这样做了,你就可以做一个简单的峰值选择。我已经为您重新编写了代码:
Fs = 48000;
x = dataSet; % 256 samples data set
fftLength = length(x); % Always make sure to be at least as long as your data.
xdft = fft(x,fftLength);
maxAmp = max(abs(xdft));
freq = [0:fftLength-1].*(Fs/fftLength); % This is your total freq-axis
freqsYouCareAbout = freq(freq < Fs/2); % You only care about either the pos or neg
% frequencies, since they are redundant for
% a real signal.
xdftYouCareAbout = abs(xdft(1:round(fftLength/2))); % Take the absolute magnitude.
[maxVal, index] = max(xdftYouCareAbout); % maxVal is your (un-normalized) maximum amplitude
maxFreq = freqsYouCareAbout(index); % This is the frequency of your dominant signal.