I have a TXT-Doc https://www.mikrocontroller.net/attachment/428580/Probe_1.txt with analog values. I'm using FFT and Pwelch in Matlab to find the frequency of my analog signal. Theoreticly the frequency should be somewhere ~300 Hz. That's why i thought about an area of 0-500 Hz.
I tried fft:
>> load pr_1.txt;
>> Fs = 1000;
>> T = 1/Fs;
>> L = length(pr_1);
>> FFT = fft(pr_1);
>> P2 = abs(FFT/L);
>> P1 = P2(1:L/2+1);
>> P1(2:end-1) = 2*P1(2:end-1);
>> f = Fs*(0:(L/2))/L;
>> plot(f,20*log10(P1))
and pwelch:
>> len = 2050;
>> h = kaiser(len,4.53);
>> pwelch(pr_1,h,[],len,Fs)
Both is showing me the same answer: Peak at ~300 Hz. But my question is how to I define the right sampling frequence Fs? If i change Fs for example to Fs=10000 instead of Fs=1000 I'll get Peak Points at ~3000 Hz instead of 300 Hz. And if I change Fs = 500, the Peak results at 150 Hz. I have the problem to understand and define the right Fs.
Assuming your provided file was generated by some measurement device, you can take the 3rd line
# Aufnahmerate [Hz]: 9997.4286613483
as your sample rate Fs. This is a fixed rate which is defined by the capturing device, just as @Irreducible said. Therefore you can't randomly change it.
The header of the file tells you also more information: It says there are 100000 samples, which is true, and also if you multiply the timeinterval per sample (5th line) with the number of samples(100000, 2nd line), you get exactly the measurement duration (4th line). From this I assume, that these values are true.
For completeness/future reference: the top content of your file:
# 2019-08-26 15:38:49.661906
# Anzahl Messwerte: 100000
# Aufnahmerate [Hz]: 9997.4286613483
# Messdauer [s]: 10.002572
# Zeitintervall je Messpunkt [ms]: 0.10002572
2.820286226094503856e+00
2.820608226282290687e+00
2.820286226094503856e+00
2.820608226282290687e+00
2.820286226094503856e+00
2.820608226282290687e+00
2.820608226282290687e+00
2.820608226282290687e+00
2.819642225722452267e+00
2.820286226094503856e+00
2.820608226282290687e+00
2.819964225907891198e+00
2.820286226094503856e+00
2.819964225907891198e+00
...