|
|
@@ -0,0 +1,63 @@
|
|
|
+FormatSpec = '%d';
|
|
|
+PointsNum = 500;
|
|
|
+N = 4;
|
|
|
+R = 4;
|
|
|
+B = 14;
|
|
|
+M = 1;
|
|
|
+
|
|
|
+K = N*(20*log10(R));
|
|
|
+Knew = 10^(K/20);
|
|
|
+
|
|
|
+BitGrowth = log2(Knew);
|
|
|
+
|
|
|
+Bmax = ceil(log2(18));
|
|
|
+x = 1:1:PointsNum;
|
|
|
+xDecim = 1:1:PointsNum/R;
|
|
|
+Fs = 50;
|
|
|
+
|
|
|
+ReadInDataId = fopen('C:/S5243_FFT_REPO/src/src/Sim/InputSignal.txt','r');
|
|
|
+InDataSignal = fscanf(ReadInDataId,FormatSpec);
|
|
|
+fclose(ReadInDataId);
|
|
|
+
|
|
|
+ReadFilteredDataId = fopen('C:/S5243_FFT_REPO/src/src/Sim/FilteredData.txt','r');
|
|
|
+FilteredData = fscanf(ReadFilteredDataId,FormatSpec);
|
|
|
+fclose(ReadFilteredDataId);
|
|
|
+
|
|
|
+InDataFft = fft(InDataSignal);
|
|
|
+InDataFft = InDataFft(1:PointsNum/2);
|
|
|
+
|
|
|
+FilteredDataPNum = PointsNum/R;
|
|
|
+
|
|
|
+FilteredDataFft = fft(FilteredData);
|
|
|
+FilteredDataFft = FilteredDataFft(1:FilteredDataPNum/2);
|
|
|
+
|
|
|
+Freqs = Fs*(1:(PointsNum/2))/PointsNum;
|
|
|
+FreqsDecim = Fs/R*(1:(FilteredDataPNum/2))/FilteredDataPNum;
|
|
|
+
|
|
|
+figure(1)
|
|
|
+subplot(2,1,1)
|
|
|
+plot(x, InDataSignal)
|
|
|
+title("In Signal")
|
|
|
+xlabel("Time")
|
|
|
+ylabel("Amp")
|
|
|
+
|
|
|
+
|
|
|
+subplot(2,1,2)
|
|
|
+plot(Freqs,abs(InDataFft))
|
|
|
+title("Single-Sided Amplitude Spectrum of InData")
|
|
|
+xlabel("f (Hz)")
|
|
|
+ylabel("Amp")
|
|
|
+
|
|
|
+figure(2)
|
|
|
+subplot(2,1,1)
|
|
|
+plot(xDecim, FilteredData)
|
|
|
+title("FilteredData")
|
|
|
+xlabel("Time")
|
|
|
+ylabel("Amp")
|
|
|
+
|
|
|
+subplot(2,1,2)
|
|
|
+plot(FreqsDecim,10*log10(FilteredDataFft))
|
|
|
+% plot(FreqsDecim,abs(FilteredDataFft))
|
|
|
+title("Single-Sided Amplitude Spectrum of FilteredData")
|
|
|
+xlabel("f (Hz)")
|
|
|
+ylabel("Amp")
|