How do I resolve the error "The signal at output port 2 of 'ftranssine2freq/MATLAB Function/ SFunction ' is a variable-size signal with a nondiscrete sample time.."
1 view (last 30 days)
Show older comments
Hello everyone I was trying some simple code to find fourier transform of two cosines of different frequency numerically i.e., without using the function fft() as my guide has advised me to calculate it numerically for some specific purpose. after running the codes I am getting following error: The signal at output port 2 of 'ftranssine2freq/MATLAB Function/ SFunction ' is a variable-size signal with a nondiscrete sample time.
function y = fcn(z)
%#codegen
y=z;
N=250;
ts=.002;
u=[0:N-1]*ts;
k=0;
for f=0:1:800
k=k+1;
y(k)=real(trapz(u,z.*exp(-1i*2*pi*f*u)));
end
plot(f, abs(y))
0 Comments
Answers (0)
See Also
Categories
Find more on Bartlett 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!