Continuous plot(x,y) for discrete data points

50 Ansichten (letzte 30 Tage)
Vineet
Vineet am 30 Dez. 2013
Beantwortet: Anil am 28 Dez. 2022
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 Kommentar
Chandeesh
Chandeesh am 25 Jul. 2022
Select the functions to represent the graph of a continuous and a discrete function.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 30 Dez. 2013
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 Kommentare
Vineet
Vineet am 30 Dez. 2013
Thank you Azzi. The stem plot is cool, especially for statistics!
Azzi Abdelmalek
Azzi Abdelmalek am 30 Dez. 2013
for statistics, maybe you need to look at
doc hist
doc bar

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

Sean de Wolski
Sean de Wolski am 30 Dez. 2013
Bearbeitet: Sean de Wolski am 30 Dez. 2013
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 Kommentar
Vineet
Vineet am 30 Dez. 2013
Thank you, Sean. That was very helpful. I tested with and without markers (default). Works great!

Melden Sie sich an, um zu kommentieren.


Anil
Anil am 28 Dez. 2022
i only have one point for x and y how can i generate a continuous plot for this

Community Treasure Hunt

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

Start Hunting!

Translated by