Continuous plot(x,y) for discrete data points

조회 수: 43 (최근 30일)
Vineet
Vineet 2013년 12월 30일
답변: Anil 2022년 12월 28일
When using plot(x,y) function, [say for example x = 1X20 matrix and y=sin(x), which means that there are only 20 data points), matlab plot comes out to be a continuous one. Is this always the case? I just started using matlab.
  댓글 수: 1
Chandeesh
Chandeesh 2022년 7월 25일
Select the functions to represent the graph of a continuous and a discrete function.

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

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 12월 30일
You can use plot for continuous plot, or stem function for discrete plot. You can also use scatter function
Example
x=0:10
y=sin(x)
plottx,y);
figure
stem(x,y);
figure
scatter(x,y)
  댓글 수: 2
Vineet
Vineet 2013년 12월 30일
Thank you Azzi. The stem plot is cool, especially for statistics!
Azzi Abdelmalek
Azzi Abdelmalek 2013년 12월 30일
for statistics, maybe you need to look at
doc hist
doc bar

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

추가 답변 (2개)

Sean de Wolski
Sean de Wolski 2013년 12월 30일
편집: Sean de Wolski 2013년 12월 30일
plot is just connecting the points with lines. If you don't want this, you can specify the marker. For example, for a red *
>> plot(0:0.1:2*pi,sin(0:0.1:2*pi),'r*')
And for more info:
doc plot
  댓글 수: 1
Vineet
Vineet 2013년 12월 30일
Thank you, Sean. That was very helpful. I tested with and without markers (default). Works great!

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


Anil
Anil 2022년 12월 28일
i only have one point for x and y how can i generate a continuous plot for this

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by