필터 지우기
필터 지우기

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