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

2 views (last 30 days)
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);

Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!