Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Help me fix this Matlab code

Status
Not open for further replies.

kosamoza

Newbie level 4
Joined
Oct 4, 2006
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,311
can any one help me in this code


clc
clear
%BPSK Transmitter
data=randint (1,100000);
data=(2*data)-1;
%AWGN Channel
EbNo_db=0:0.5:10;
No=10.^(0.1*-EbNo_db);
for k=1:length(EbNo_db)
noise =sqrt(No(k)/2).*randn(1,100000);
end
%BPSK Receiver
received = data + noise;
for i=1:length(received)
if(received(i)>=0)
est_bits(i)=1;
else if (received(i)<0)
est_bits=0;
end
end
end
errors = sum (xor(data,est_bits));
Pe(EbNo_db+1)=errors/length(data);
semilogy(EbNo,Pe);
 

jody

Member level 3
Joined
Sep 14, 2006
Messages
57
Helped
7
Reputation
14
Reaction score
1
Trophy points
1,288
Activity points
1,527
Help with this code

what this? vhdl-ams!
 

kosamoza

Newbie level 4
Joined
Oct 4, 2006
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,311
Help with this code

Matlab Coce
& I need help about it
for BPSK Code
 

cedance

Advanced Member level 2
Joined
Oct 24, 2003
Messages
551
Helped
30
Reputation
60
Reaction score
7
Trophy points
1,298
Location
Germany
Activity points
4,622
Help with this code

what help exactly? u need the code to be explained or debugged?
 

kosamoza

Newbie level 4
Joined
Oct 4, 2006
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,311
Help with this code

The code have some errors
when I run the code there is an errror I can'y figure ut
& I want help in this if u could run it & figure out where is the proplem I will be grateful
 

rakesh_vnit

Member level 3
Joined
Sep 4, 2007
Messages
54
Helped
4
Reputation
8
Reaction score
1
Trophy points
1,288
Location
india
Activity points
1,714
Re: Help with this code

i was able to debug 2 things in ur code....n there is a 3rd one which is some kind of a logical mistake. as i dont know wat u r upto in mean ur approach i cant help u in that...
but the rest 2 are here...

1.line 23...Pe(EbNo_db+1)=errors/length(data);
the index that u r usin is in double variable form which is not applicable for indexin...so change it to unsigned int by usin ... "EbNo_db=uint16(EbNo_db);" before the above mentioned line.

2. silly one u might have over looked it...the variable name in semilogy should be EbNo_db n not EbNo....

3. the vectors that ur r plotin, ie., in semilogy should be of the same length...this is a logical error...make sure of ur formula n try again. if those two should be plotted one upon the other then they should be of the same length...
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top