this code keeps plotting points but I want a smooth continuous line…How do I do that?
for x = -3*pi:pi/10:3*pi
if sin(x) > 0
y = sin(x);
else
y = 0;
end
plot(x, y);
end

댓글 수: 2

Hayeon Chae
Hayeon Chae 2023년 2월 16일
for x = -6*pi:pi/10:6*pi
if sin(x) > 0
y = sin(x);
else
y = 0;
end
plot(x, y, 'bo');
end
Hayeon Chae
Hayeon Chae 2023년 2월 16일
I fixed it

댓글을 달려면 로그인하십시오.

 채택된 답변

Dyuman Joshi
Dyuman Joshi 2023년 2월 16일
x = -6*pi:pi/10:6*pi;
y = sin(x);
f = max(sin(x),0);
plot(x, f, 'b-o') %remove o if you don't want markers
ylim([-0.2 1.2])

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

질문:

2023년 2월 16일

댓글:

2023년 2월 16일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by