Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

how to check the random bits that were found?

1 Ansicht (letzte 30 Tage)
adriane duarte
adriane duarte am 12 Sep. 2020
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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 Kommentare
Sindar
Sindar am 13 Sep. 2020
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 am 15 Sep. 2020
thanks for the help.
I'll do the code check.

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by