フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how to check the random bits that were found?

1 回表示 (過去 30 日間)
adriane duarte
adriane duarte 2020 年 9 月 12 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Good night people.
I made the code below to add a watermark to an RF signal.
I'm having trouble testing whether b_w is equal to Bit_wat1.
The real part is right (with the same b-inf = Bits_ale = s), but the Imag part (Bit_wat1 and b_w) that I can't get right.
Could someone give me a guess ????
clc
% BPSK - usa mudança de fase anti-podal para codificar um unico bit
M = 2;
% número de bits (símbolos)
N = 16;
% Não sei o que é????
nS = 1;
% Bits de duração
Tb=1;
% frequência da portadora
fc = 1e6;
% Tempo
t = 0:(Tb/(nS)):N*Tb-(Tb/(nS));
% comprimento - em função do tempo e dos numeros de bits
nt = round((N*t));
% Gera bits aleatórios para o sinal
Bits_ale = rand(1,length(nt))>0.5;
% Modulação BPSK - Transforma 0 -> -1; 1 -> 1
s = 2 * Bits_ale-1 ;
% Gera bits de marca d'água aleatórios
Bit_wat = rand(1,length(nt))>0.5;
Bit_wat1 = 2 * Bit_wat - 1;
% Transmissor
Tx = s;
% Gera marca d'água a XX grau do ideal
wat = 28*(pi/180)*(Bit_wat1);
y=zeros(N,1);
for k=1:N
if (Bit_wat1 ==1)
y = Tx .*exp(1i.*(2*pi*fc*t+wat)) ;
else
y = Tx .*exp(1i.*(2*pi*fc*t-wat)) ;
end
end
b_inf=zeros(1,N);
b_w=zeros(1,N);
for w= 1:N
if real(y(w)) >= 0
b_inf(w) = 1;
else
b_inf(w) = 0;
end
end
for x= 1:N
if imag(y(x)) >= 0
b_w(x) = 1;
else
b_w(x) = -1;
end
end
re=real(y);
i=imag(y);
  2 件のコメント
Sindar
Sindar 2020 年 9 月 13 日
This loop doesn't involve the loop variable k - you're doing the same thing N times:
for k=1:N
if (Bit_wat1 ==1)
y = Tx .*exp(1i.*(2*pi*fc*t+wat)) ;
else
y = Tx .*exp(1i.*(2*pi*fc*t-wat)) ;
end
end
Also, these loops
b_inf=zeros(1,N);
b_w=zeros(1,N);
for w= 1:N
if real(y(w)) >= 0
b_inf(w) = 1;
else
b_inf(w) = 0;
end
end
for x= 1:N
if imag(y(x)) >= 0
b_w(x) = 1;
else
b_w(x) = -1;
end
end
can be replaced with:
b_inf = double( real(y) >= 0 );
b_w = -1 + 2*( imag(y) >= 0 );
adriane duarte
adriane duarte 2020 年 9 月 15 日
thanks for the help.
I'll do the code check.

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by