フィルターのクリア

How to plot points on a line

115 ビュー (過去 30 日間)
jacob Mitch
jacob Mitch 2019 年 10 月 10 日
コメント済み: jacob Mitch 2019 年 10 月 12 日
Say I have a random sequence of such as new=randn(5,1) which produces y values of
ans =
-0.9118
0.0494
1.0780
0.3082
0.2996
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
plot(new)
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
datapoints=
-0.9118
0.3082 or
datapoints=-0.9118 0.3082
I hope this make sense and thanks for the help.

採用された回答

Fabio Freschi
Fabio Freschi 2019 年 10 月 10 日
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
plot(new);
% new data points
datapoints = [-0.9118 0.3082]
% plot with blue circles
plot(datapoints,'bo')
  6 件のコメント
jacob Mitch
jacob Mitch 2019 年 10 月 12 日
Hi there, sorry it was just meant to be
for z=2:x
if z==x
return
jacob Mitch
jacob Mitch 2019 年 10 月 12 日
This may be late but you're a genius. Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by