1

I have two vectors. One is of noise and one is of my signal. If I want to add noise vector to signal vector how can i do it. My noise dimension is 41001x1 and my signal is 88200x1.

3
  • 2
    Why not add a random vector of the same size as the signal ? Also you should provide a minimal and reproducible example, check: How to create a Minimal, Reproducible Example Commented Dec 24, 2020 at 9:15
  • I cant. I am suppose to only add these two vectors Commented Dec 24, 2020 at 9:33
  • 1
    Then you need to explain how it should be done ! Matlab can not sum two vectors of different length. Commented Dec 24, 2020 at 9:44

1 Answer 1

2

Here is the code to product a signal and noise of the dimensions you mentioned:

time = (1:88200)';
sig = sin(0.005 * time);
noise = 0.1 * randn(41001, 1);

Since you cannot add two vectors of the same length, I chose to replicate the noise signal by repeating it so that it is the same length as sig:

multiplier = ceil(length(sig) / length(noise));
noise = repmat(noise, multiplier, 1);
noise = noise(1:length(sig));

Now the noise and sig are the same length they can be added and plotted together

plot(time, noise + sig)

In this answer, I'm assuming that noise and sig have the same sample rate, but noise is just too short for some reason. If the noise signal is at a different sample rate, then you would want to use interp1 or resample to get the same sample rate and number of points.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.