marking a points in a curve that match condition

2 ビュー (過去 30 日間)
fima v
fima v 2017 年 3 月 16 日
回答済み: Image Analyst 2017 年 3 月 17 日
Hello , i have a plot from two vectors X and Y how can i mark on the plot all the point in which the Y values are between 5 and 7?
thanks
  1 件のコメント
Jan
Jan 2017 年 3 月 16 日
Please add some test data, which match your code. Currently the information is vague only and answering must be based on guessing.

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

採用された回答

Image Analyst
Image Analyst 2017 年 3 月 17 日
Try this:
numPoints = 20;
offset = 0.05; % How much away from the marker the text should be.
x = sort(rand(1, numPoints));
y = 10 * rand(1, numPoints);
plot(x, y, 'g', 'LineWidth', 2);
hold on;
index = (5 < y & y < 7);
plot(x(index), y(index), 'or', 'LineWidth', 2);
grid on;
for k = 1 : length(y)
if index(k)
caption = sprintf('x=%.2f, y=%.2f', x(k), y(k));
text(x(k) + offset, y(k) + offset, caption, 'BackgroundColor', 'y');
end
end

その他の回答 (1 件)

Jan
Jan 2017 年 3 月 16 日
x = 1:100;
y = rand(1, numel(x)) * 10;
plot(x, y, 'g');
hold('on');
index = (5 < y & y < 7);
plot(find(index), y(index), 'or');

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by