www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/DesignAnNCOExample.m
%% Design an NCO Source %% % *Note*: This example runs only in R2016b or later. If you are using an % earlier release, replace each call to the function with the equivalent % |step| syntax. For example, myObject() becomes step(myObject). %% % Design an NCO source according to given specifications. F0 = 510; % Output frequency = 510 Hz df = 0.05; % Frequency resolution = 0.05 Hz minSFDR = 96; % Spurious free dynamic range >= 96 dB Ts = 1/8000; % Sample period = 1/8000 sec dphi = pi/2; % Desired phase offset = pi/2; %% % Calculate number of accumulator bits required for the given frequency % resolution Nacc = ceil(log2(1/(df*Ts))); % Actual frequency resolution achieved actdf = 1/(Ts*2^Nacc); % Calculate number of quantized accumulator bits % required from the SFDR requirement Nqacc = ceil((minSFDR-12)/6); % Calculate the phase increment phIncr = round(F0*Ts*2^Nacc); % Calculate the phase offset phOffset = 2^Nacc*dphi/(2*pi); hnco = dsp.NCO('PhaseIncrementSource', 'Property', ... 'PhaseIncrement', phIncr,... 'PhaseOffset', phOffset,... 'NumDitherBits', 4, ... 'NumQuantizerAccumulatorBits', Nqacc,... 'SamplesPerFrame', 1/Ts, ... 'CustomAccumulatorDataType', numerictype([],Nacc)); y = hnco(); % Plot the mean-square spectrum of the 510 Hz sinewave % generated by the NCO periodogram(double(y),hann(length(y),'periodic'),[],1/Ts,'power');