found unsupported dynamic matrix type at output port 0
2 views (last 30 days)
Show older comments
Amruta Radder
on 11 Apr 2016
Commented: Keerthi Venkat Reddy Mokka
on 13 Mar 2018
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
0 Comments
Accepted Answer
Walter Roberson
on 11 Apr 2016
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.
0 Comments
More Answers (1)
Tim McBrayer
on 11 Apr 2016
Edited: Tim McBrayer
on 11 Apr 2016
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.
2 Comments
Keerthi Venkat Reddy Mokka
on 13 Mar 2018
can you please tell me... what are the changes you did in your code?
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!