Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Adding noise to a Square wave in Matlab

  1. May 8, 2010 #1
    Hi, I've got a square wave: x = square(2*pi*10*t);
    with time vector: t=0:0.001:2;

    I've also got a random noise signal: r=randn(1,10000);

    I want to add the noise signal to the square wave, but I can't add them because they aren't of the same dimensions. I know I can use awgn(x,snr) but I want to use my r function instead if it's possible.

    How can I make the noise signal a function of the time vector?

    Thanks in advance.
  2. jcsd
  3. May 8, 2010 #2
    Any reason why you dont just use this:

    x = square(2*pi*10*t);

  4. May 8, 2010 #3
    ahh ofcourse, length(x)! I didn't think about that, thanks for your help!
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook