Please house, how can i successfully convert this matlab fft code to a verilog hdl for cyclone III fpga..?? it keeps giving me error that the function "fft" is not explicit even after making it extrinsic using the "coder.extrinsic" command.
2 views (last 30 days)
Show older comments
function [xfft,ffc] = My_function(f1,f2,f3) Fs = 2000; %sampling frequency should be at least twice signal frequency %in accordance with Nyquist. Ts = 1/Fs; %sampling frequency. dt = 0:Ts:4-Ts; %signal duration. %f1 = 20; % frequency of first signal in Hz. %f2 = 70; % frequency of second signal in Hz. %f3 = 150; % frequency of third signal in Hz.
% Y = A sin(2*pi*ft+theta); theta assume to be zero.
y1 = 10*sin(2*pi*f1*dt); y2 = 10*sin(2*pi*f2*dt); y3 = 10*sin(2*pi*f3*dt); y4 = y1+y2+y3;
% subplot(4,1,1); % plot(dt,y1,'r'); % subplot(4,1,2); % plot(dt,y2,'r'); % subplot(4,1,3); % plot(dt,y3,'r'); % subplot(4,1,4); % plot(dt,y4,'r');
coder.extrinsic('fft','nextpow2');
N =length(y4); % length of time domain signal. N2=2^nextpow2(N); % length of time domain signal in power of 2. ff = fft(y4,N2); %ffl = ff(1:nfft2/2); % left side of the symetric function ff. xfft = Fs*(0:N2-1)/N2; %plot(abs(ff)); %plot(abs(ffl)); %plot(xfft,abs(ffl)); %ffl = ffl/max(ffl); % to normalize amplitude of frequency domain signal. ffc = ff(1:N2); ffc = ffc/max(ffc); %plot(abs(ffc));
% coder.extrinsic declaration coder.extrinsic('subplot','plot','xlabel','ylabel','title');
subplot(2,1,1); plot(dt,y4,'r') xlabel('Time (s)'); ylabel('Amplitude'); title('Time Domain Signal');
subplot(2,1,2); plot(xfft,abs(ffc),'r') xlabel('Frequency (Hz)'); ylabel('Normalize Amplitude'); title('Frequency Domain Signal'); end
0 Comments
Answers (0)
See Also
Categories
Find more on Transforms 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!