Here is a revised version of the function above that is working, thanks to Paul R remarks.
function [FiltredSignal]=Filter(Signal,n)
"% n= nbr of spectral components to keep "
timelen=length(Signal);
FT=fft(Signal); "% fast fourrier transform"
FTcopy=FT/timelen; "% Copy for spectral analysis"
FTcopy(floor(timelen/2+1):end)=[]; "% cut at nyquist point"
"% sort FT2 in descending amplitude order"
sortedFT=sort(abs(FTcopy),'descend');
"% spectral selection --> n biggest amplitudes"
FiltredFT=zeros(1,timelen);
for i=1:n
freq=find(abs(FTcopy)==sortedFT(i));
FiltredFT(freq)=FT(1,freq);
end
"% return filtred signal time serie with complex conjugate reconstruction"
FiltredData=ifft(FiltredFT,'symmetric');