0
$\begingroup$

Hi I need to simulate a simple multipath channel in matlab through which I can send my OFDM transmission signal, I want to test my OFDM receiver design. So far I have:

%% Passing through Channel
nIFFT = 4096;

% Create channel
channel = randn(1,nIFFT) + sqrt(-1)*randn(1,nIFFT);

% cext_data is the signal to be transmitted
after_channel = filter(channel, 1, cext_data); 
wavwrite(after_channel,'ofdm_tx8khz.wav');

I get a warning when I run the transmitter:

Warning: Data clipped during write to file:ofdm_tx8khz.wav

and when I run the receiver I get:

Index exceeds matrix dimensions.

Error in ofdm_rx (line 26)

chunk2 = signal((s+nIFFT):(s+nIFFT+nCyclic-1));

I was really hoping someone could help me simulate a multipath channel for my OFDM program.

$\endgroup$

closed as off-topic by Deve, Jim Clay, lennon310, Jason R, Phonon May 13 '14 at 3:54

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "General programming questions are off-topic here, but can be asked on Stack Overflow." – Deve, Jim Clay, lennon310, Jason R, Phonon
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Personally I don't like when people are using sqrt(-1) for imaginary unit. First of all MATLAB has in-built variables: i, (1i), j. Secondly, from mathematical point of view solution for $\sqrt{-1}$ is both: $i$ and $-i$. $\endgroup$ – jojek Apr 24 '14 at 11:58
1
$\begingroup$

Wav files expect values from -1 to +1. You are probably exceeding those limits when you filter the signal through the channel model. After the channel filter add the following:

after_channel = after_channel / max(abs(after_channel));

I suspect, though, that you will still have a problem. I believe that wavwrite ignores the imaginary part of complex data, so you will be losing that part of the signal.

$\endgroup$
  • $\begingroup$ Hi, thank you for your answer, I did try that and the error persists. What should I do? Is there any other way I could simulate a simple multipath channel for my program ? $\endgroup$ – user8572 Apr 24 '14 at 12:09
  • 2
    $\begingroup$ Then normalize it: after_channel_norm = after_channel ./ max(abs(after_channel)) $\endgroup$ – Deve Apr 24 '14 at 12:37
  • $\begingroup$ @Deve Good call. Modified the answer. $\endgroup$ – Jim Clay Apr 24 '14 at 13:48
  • $\begingroup$ Thanks for that, that did solve the data being clipped error however I am still getting the second error during the reception of the signal. The line with the error is in my cross-correlation i have made a number of changes but it still is giving the same error, here's the fucntion: codetidy.com/4165 $\endgroup$ – user8572 Apr 24 '14 at 15:26
  • $\begingroup$ @user8572 Questions about programming problems should really go to StackOverflow, not Signal Processing. $\endgroup$ – Jim Clay Apr 24 '14 at 17:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.