plot with a few sample marked.

1 回表示 (過去 30 日間)
Minghao Dong
Minghao Dong 2019 年 11 月 17 日
回答済み: Star Strider 2019 年 11 月 17 日
Hi Team,
May I ask your help? I would like to plot with a few samples marked out in matlab.
For example, I want to plot a cos function
x=[1:0.01:40];
y=cos(x);
plot(x,y)
But how can I mark the points with amplitude smaller than 0.5 with, for example, bubbles?
Thank you team!
Allen

回答 (1 件)

Star Strider
Star Strider 2019 年 11 月 17 日
Try these:
x= 1:0.01:40;
y = cos(x);
L1 = y <= 0.5; % Logical Index: y <= 0.5
figure
plot(x,y)
hold on
plot(x(L1), y(L1), 'o')
hold off
L2 = abs(y) < 0.5; % Logical Index: y <= 0.5 & y >= -0.5
figure
plot(x,y)
hold on
plot(x(L2), y(L2), 'o')
hold off
Experiment to get different results.

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by