Why is my plot shaking but not plotting the noise?
1 view (last 30 days)
Show older comments
Jorge Arturo Clares Pastrana
on 16 Feb 2022
Commented: Jorge Arturo Clares Pastrana
on 16 Feb 2022
clear;
clc;
for x = 0:(pi/200):(2*pi)
e = rand;
y = x*sin(x)+(0.5*e);
x_star = [0:(pi/200):(2*pi)].';
y_star = x_star.*sin(x_star)+0.5*e;
figure(1)
plot(x_star,y_star)
grid on
title('Hw1');
xlabel('x');
ylabel('f(x)');
end
0 Comments
Accepted Answer
Arif Hoq
on 16 Feb 2022
Edited: Arif Hoq
on 16 Feb 2022
x = 0:pi/200:(2*pi);% does't need
e = rand; % does't need
y = x.*sin(x)+(0.5*e); % does't need
x_star = 0:(pi/200):(2*pi); % x_star and x same
y_star = x_star.*sin(x_star)+0.5*rand(size(x_star)); % adding noise 0.5*rand(size(x)) y_star and y same
figure(1)
plot(x_star,y_star)
grid on
title('Hw1');
xlabel('x');
ylabel('f(x)');
2 Comments
Arif Hoq
on 16 Feb 2022
Or simply
x = 0:pi/200:(2*pi);
e = 0.5*rand(size(x)); % noise
y = x.*sin(x)+e;
figure(1)
plot(x,y)
grid on
title('Hw1');
xlabel('x');
ylabel('f(x)');
More Answers (0)
See Also
Categories
Find more on Communications Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!