Filter löschen
Filter löschen

How to plot points on a line

46 Ansichten (letzte 30 Tage)
jacob Mitch
jacob Mitch am 10 Okt. 2019
Kommentiert: jacob Mitch am 12 Okt. 2019
Say I have a random sequence of such as new=randn(5,1) which produces y values of
ans =
How would I plot these points as a line on a graph ie x=0, y=-0.9118 x=1 y=0.0494 etc or a line connecting the y values. I have tried
I would then like to add points to the graph as blue dots ie onto the graph of new=randn(5,1) add blue dots at the points from code such as
0.3082 or
datapoints=-0.9118 0.3082
I hope this make sense and thanks for the help.

Akzeptierte Antwort

Fabio Freschi
Fabio Freschi am 10 Okt. 2019
I suggest you to check hold on, and the LineSpec of the command plot
% your data
new = rand(5,1);
% open figure and retain current plot
figure, hold on
% new data points
datapoints = [-0.9118 0.3082]
% plot with blue circles
  6 Kommentare
jacob Mitch
jacob Mitch am 12 Okt. 2019
Hi there, sorry it was just meant to be
for z=2:x
if z==x
jacob Mitch
jacob Mitch am 12 Okt. 2019
This may be late but you're a genius. Thank you!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)


Mehr zu Line Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by