Does MATLAB code retain its accuracy when is executed in dsp kit?

2 vues (au cours des 30 derniers jours)
Georges Theodosiou
Georges Theodosiou le 8 Fév 2021
Ladies, Gentlemen,
Please let me say you that following code when is executed in MATLAB online R2020b its resaults have excellent accuracy. Is it possible retain its accuracy when is executed in dsp kit?
SampFreq = 16000;
Segm = 1:1600;
%% Generates signal
FirstHarmFreq = 101;
FirstHarmAngles = FirstHarmFreq*2*pi/SampFreq*Segm+(1.9*pi);
SinFirstHarmAngles = sin(FirstHarmAngles);
SecondHarmAngles = FirstHarmFreq*2*2*pi/SampFreq*Segm+(0.9*pi);
SinSecondHarmAngles = sin(SecondHarmAngles);
ThirdHarmAngles = FirstHarmFreq*3*2*pi/SampFreq*Segm+(0.3*pi);
SinThirdHarmAngles = sin(ThirdHarmAngles);
Xn = SinFirstHarmAngles+SinSecondHarmAngles+SinThirdHarmAngles;
%% DFT Grid
fftFirstHarm = 110;
LowerLimit = fftFirstHarm-10;
UpperLimit = fftFirstHarm+10;
TestFreqs = LowerLimit:0.1:UpperLimit;
TestPowerSpectrum = ones(1,201);
for m = 1:201
TestAngles = TestFreqs(m)*2*pi/SampFreq*Segm;
XnCos = sum(Xn.*cos(TestAngles));
XnSin = sum(Xn.*-sin(TestAngles));
TestPowerSpectrum(m) = XnCos.^2+XnSin.^2;
end
[maxPowerSpectrum, testFreqIndex] = max(TestPowerSpectrum);
fundFreq = TestFreqs(testFreqIndex);
disp(fundFreq);

Réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by