Why is my plot shaking but not plotting the noise?
조회 수: 14 (최근 30일)
이전 댓글 표시
Jorge Arturo Clares Pastrana
2022년 2월 16일
댓글: Jorge Arturo Clares Pastrana
2022년 2월 16일
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
채택된 답변
Arif Hoq
2022년 2월 16일
편집: Arif Hoq
2022년 2월 16일
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
Arif Hoq
2022년 2월 16일
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)');
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Filter Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

