?? nco_sin_tb.m
字號:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Altera NCO Compiler version 2.3.1% file : NCO_sin_tb.m%% Description : The following Matlab testbench excercises the NCO model NCO_sin_model.m% generated by Altera's NCO Compiler Megacore and outputs the sine and cosine waveforms% to the variables sin_out and cos_out respectively%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Parameter description% N : the length of input and output arrays% fs : the desired sampling rate. For Multi-channel NCO's the channelized sample rate is fs/M % ehre M is the number of channels%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%N=2048*1;fs = 1.0E8;% Input arrays% phi_inc_i : input phase increment : Length N (required)phi_inc_i = 42949673.*ones(1,N);% freq_mod_i : frequency modulation input : Length N (optional)freq_mod_i = zeros(1,N);% phase_mod_i : phase modulation input : Length N (optional)phase_mod_i = zeros(1,N);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function call to generated nco function[sin_out,cos_out] = NCO_sin_model(phi_inc_i,phase_mod_i,freq_mod_i);fid_s = fopen('fsin_o_NCO_sin_matlab.txt','w');for i=1:N fprintf(fid_s,'%f\n',sin_out(i));end% Plot Channel 0 Time-Domain Outputxvalst = (0:1/fs:((N/1)-1)/fs);figure,stairs(xvalst,sin_out(1:1:N),'r');title ('Time-Domain Plot of NCO Channel 0 Output');grid on;zoom on;xlabel ('Time');ylabel ('Amplitude');ncofftwinplot(sin_out(1:1:N),fs,0,'r');
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -