-2

So I have two signals signal1 and signal2, both signal were initiated with:

signal1=zeros(x,1) and signal2=zeros(y,1).

The data for signal one looks like this

1.0000+1.0000i    
1.0000-1.0000i    
1.0000+1.0000i    
1.0000-1.0000i    
0.0000 + 0000i    
0.0000 - 0000i

My first question is how do I filter out the values 0+0i

And how can I compare the bits of the two signals to find the errors?

alditis
  • 4,633
  • 3
  • 49
  • 76
user8572
  • 1
  • 2

2 Answers2

1

This feels like a homework assignment, and I hate just solving homework assignments outright. Perhaps this will help though.

You mention bits, so I'll guess the "signals" are intended to be some kind of modulated data. I'll just guess at QPSK from the example data. The P in QPSK means phase. Supose I had two functions that were of the form

    x1=exp(j*m1(t))  

and

    x2=exp(j*m2(t)),   

where m1(t) and m2(t) represent a message encoded in the phase of the complex signal. Do I really just want to get to m1(t)-m2(t)?

Although you could take the angle of them individually, you run into troubles with the 0's that don't have a defined angle.

I offer two axioms to point you in the direction I would go.

    conj(e(ja))  = e(-ja)
    a^b * a^c  = a^(b+c)

If you are new to matlab help on "ops" and help on "find" are probably the best spots to start. Many new folks don't grasp the difference between * and .*, though that tends to be based on how much linear algebra background they have. Later be ready for matlab and others to tell you you did something with find that you could do more efficiently other ways, but conceptually I think find is an easier starting point.

    idx=find(abs(a-b)<.001)    
    idx=find(abs(a-zero)<.001) | abs(b-zero)<.001 )

returns vectors of indexes where the expression of the find is true.

apuntured=a; apuntured[idx]=[]; bpunctured=b; bpunctured[idx]=[];

delete the values at the given indexes and pack the resulting vectors.

For complex values the functions real(), imag(), abs(), and angle() extract rectangular and polar components.

dennis
  • 221
  • 1
  • 5
  • Haha, this is not my homework assignment. I am trying to make an OFDM system using QPSk which will send and receive .wav files. These signals I have mentioned above are QPSK signals with normal values and 0+0i values -which are actually from the semi-realistic offset or delay I have given to my signal. I have made a copy of the qpsk signal before putting it through to the IFFT, and wanted to plot this signal without the 0+0i and find the error by comparing it with the demodulated output signal at the rx, however I am new to matlab and I cant seem to get the correct output, with whatever I try. – user8572 Apr 28 '14 at 23:42
  • Perhaps include some of the matlab you trying and an explanation of the discrepancy between the output you got and the output you expected. – dennis Apr 29 '14 at 06:01
  • the whole OFDM program runs in a loop ii:length(EbN0dB) the qpsk spectrum before going into ifft is x and the spectrum coming out of the fft is y error(ii)= size(find(x-y),2); i get a matrix out of bounds error – user8572 Apr 29 '14 at 16:10
  • @user8572 The argument to a find should be a boolean expresion. Typically a vector boolean. Not sure that would give a matrix out of bounrs error though. Easy enough to fix with a `find(abs(x-y)>.001)` type expression instead. Make sure you haven't inadvertantly declared a variable with name size or find. Separate the expression `tempvar=size(find(...))` and `error(ii)=tempvar` to isolate which side of the expression is giving you the error. If x and y are different lengths I would expect an error, but think it would be different. – dennis Apr 29 '14 at 21:43
  • @user8572 If still don't find it. Put a `keyboard;` command before the line in question. When it hits that line you will get a `K>>` prompt. Your workspace will be exactly as it was leading up to that command, and you can evaluate the command one component at a time at the command line. `return` will resume the program, `dbquit` will terminate the program and return you to the normal prompt. Sorry your introduction to matlab has been so rocky, but I promise it can be powerfully useful. – dennis Apr 30 '14 at 09:03
0

To get rid of zeros signals you can just loop over you signal1. Something like this (untested though)

signal3=0;
j=0;
for i=1:size(signal1)
  if(real(signal1(i))==0 && imag(signal1(i))==0)
    signal3(j)=signal(i)
    j=j+1;
  end
end
signal1=signal3;
spieb
  • 73
  • 1
  • 1
  • 5
  • the whole OFDM program runs in a loop ii:length(EbN0dB) the qpsk spectrum before going into ifft is x and the spectrum coming out of the fft is y error(ii)= size(find(x-y),2); i get a matrix out of bounds error – user8572 Apr 29 '14 at 16:12