
Adding Noise to Signal through Rand function?
46 views (last 30 days)
Show older comments
Syed Adeel
on 10 Apr 2020
Commented: Image Analyst
on 11 Apr 2020
Hello everyone, I just want a simple help as I am new to matlab.
I want to add Noise to my Signal through rand function but its giving error. Kindly if anyone can see how am i doing it wrong. Thoguh its just few lines from a long code which works perfectly without this noise addition.
noise = 2*rand (size(time));
y2t=noise+y22t; // y22t is the signal
plot(time*1e9,y2t,'-k','LineWidth',2);
xlabel('Time - [ns]');ylabel('Amplitude - [V]');
hold on;
grid on;
0 Comments
Accepted Answer
Image Analyst
on 10 Apr 2020
Edited: Image Analyst
on 10 Apr 2020
Try this:
t = 1 : 50; % Whatever.
y22t = 2 * sin(2 * pi * t / 15);
subplot(2, 1, 1);
plot(t, y22t, 'b-', 'LineWidth', 2);
grid on;
xlabel('Time - [ns]', 'FontSize', 15);
ylabel('ytt', 'FontSize', 15);
title('Noise-free y22t', 'FontSize', 15);
noise = 2*rand (size(t)); % To go on both sides of the signal, use 2*rand (size(t)) - 1
y2t=noise+y22t; % y22t is the signal
subplot(2, 1, 2);
plot(t,y2t,'-k', 'LineWidth',2);
xlabel('Time - [ns]', 'FontSize', 15);
ylabel('Amplitude - [V]', 'FontSize', 15);
title('Noisy y22t', 'FontSize', 15);
hold on;
grid on;

Don't use time as the name of your variable since it's the name of a built-in function.
2 Comments
Image Analyst
on 11 Apr 2020
Yes, 2 is the amplitude of the noise. It can be whatever you want.
Sorry I can't help with the second part. I don't have the Symbolic Toolbox and haven't dealt with Lalace Transforms since I was an undergraduate many decades ago.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!