how to eliminate zeros in the output of fast fourier transform (matrix / array)?
Show older comments
I use simulink to find the frequency domain value of a sine signal that consists of two frequencies using fast fourier transform and then use findpeaks to find the value of each peak it gets. By using a zero order hold of 1e-3 and a buffer of 1000 and a time of 10 seconds so that the discrete matrix value becomes [11x1000] but there is an error so it can't be entered into findpeaks because I think it comes from the value t = 0 is all value 0 so that at [1x1000] there is a leading zero. I have used a lot of code but nothing works, is there any way to help me find out where the error is?
one example is I use the code below and I think because I omitted [1x1000] at the beginning so the rest becomes [10x1000] but it says an error because the number of elements doesn't match and I don't understand why.
in the way below is still the same, which part is lacking please I really need help
I also attach the workspace if possible it can be more helpful to understand
function y = fcn(u)
a = fftshift(u);
v = nonzeros(a');
y = reshape(v,1000,10);
function y = fcn(u)
y = u;
y(y==0) = [];
3 Comments
Paul Hoffrichter
on 4 Jan 2021
I do not have simulink, so maybe that is why my load of 'file.mat' gives me only this:
out =
1×6 uint32 row vector
3707764736 2 1 1 1 3
Naufal Arfani
on 4 Jan 2021
Naufal Arfani
on 4 Jan 2021
Accepted Answer
More Answers (0)
Categories
Find more on Spectral Measurements 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!
