found unsupported dynamic matrix type at output port 0

4 次查看(过去 30 天)
hi. I am working on Fast Fourier transform here i am converting FFT into HDL code. While converting i am getting error " Found unsupported dynamic matrix type at output port :0 i.e is z. My code is as below
function z=Fast_Fourier_Transform(x,nfft)
N=length(x);
z=complex(zeros(1,nfft));
Sum=complex(0);
for k=1:nfft
for jj=1:N
a=-2*pi*(jj-1)*(k-1)/nfft;
a1=cos(a)+1j*sin(a);
Sum=Sum+x(jj).*a1;
end
z(k)=Sum;
Sum=0;% Reset
end
return
testbench:
Fs = 150; % Sampling frequency
t = 0:1/Fs:1;
f = 5;
nfft = 1024;
x= cos(2*pi*t*f);
z=Fast_Fourier_Transform(x,nfft);
z = z(1:nfft/2);
mx = real(z);
% Frequency vector
f = (0:nfft/2-1)*Fs/nfft;
% Generate the plot, title and labels.
figure(1);
plot(t,x);
title('Sine Wave Signal');
xlabel('Time (s)');
ylabel('Amplitude');
figure(2);
plot(f,mx);
title('Power Spectrum of a Sine Wave');
xlabel('Frequency (Hz)');
ylabel('Power');
In workflow advisor i am getting error at last point i.e near hdlcode generation step. code is not reaching at this point and error is at same place
for jj=1:N
a=-2*pi*(jj-1)*(k-1)/nfft;
a1=cos(a)+1j*sin(a);
Sum=Sum+x(jj).*a1;
end
I am unable to debug this error please do help for my further process. THANK YOU

采纳的回答

Walter Roberson
Walter Roberson 2016-4-11
Remember that HDL is dealing with hardware. There is no memory allocation. Every array has to have a fixed maximum size so that the HDL process can generate enough hardware memory cells. If you invoke the routine multiple times with different nfft then code in the largest of the nfft as the maximum size. I believe you would do that using coder.varsize()
What I do not know at the moment is whether there is a way to configure the maximum size through a Constant Block or similar, to allow it to be a parameter of the system as a whole.

更多回答(1 个)

Tim McBrayer
Tim McBrayer 2016-4-11
编辑:Tim McBrayer 2016-4-11
The size of z is clearly dependent on the value of an input variable:
z=complex(zeros(1,nfft));
Try it with an actual constant instead of nfft, and see how it goes.

类别

Help CenterFile Exchange 中查找有关 Code Generation 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by