Skip to content
Snippets Groups Projects
Commit 186e7047 authored by Mehdi Khairy's avatar Mehdi Khairy
Browse files

working least square approximation

parent 1d1ac225
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,24 @@ function sym_array = gen_sym_array(nb_freq, FS, freq_step, nb_sample, tx_offset)
end
endfunction
% This function return the a "least square calculation" of two sequence
% seq 1 <= seq2
function res = lsq(seq1, seq2)
lseq1 = length(seq1);
lseq2 = length(seq2);
totlen = 2*lseq1 - 1 + lseq2;
tmpseq2 = zeros(1, totlen);
tmpseq2(lseq1+1:lseq1+lseq2) = seq2;
nbres = lseq2 - lseq1 + 1;
res = zeros(1, nbres);
for i = 1:nbres
res(i) = sum(abs(seq2(i:i-1+lseq1) .- seq1).^2);
end
endfunction
function np = gennoise(power, len)
np = (sqrt(1/2)*randn(1,len)+j*sqrt(1/2)*randn(1,len)) * sqrt(power);
endfunction
......@@ -66,8 +84,13 @@ costas_mod = modulate(costas, sym_array);
% signal is now containing a fake frame of FT8
% needs to add noise power calculation
Pn = 0.1; % Noise power relative to signal power
Pn = 0.8; % Noise power relative to signal power
signoise = signal + gennoise(Pn, length(signal));
corresigcost = xcorr(signoise, costas_mod);
plot(abs(corresigcost));
figure
lsqsig = lsq(costas_mod, signoise);
plot(lsqsig);
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment