How to highlight a moving data point

Hi,
I have an animated plot, the dynamic graph is a mathermatical model based on the 2 points on the other static graph. The 2 points are - one that is fixed at the start of the static graph, the other is a moving point that moves as k (loop control variable) increases. I want to highlight these two points to improve my graph. Below I have pasted a still of my graph and what I am trying to achieve and my code.
Hope my question is clear, any help is really appreciated.
MATLABhelp.png
%best fit calculations
y1 = Mean(1);
x1 = Mean_step(1);
y2 = max_cap./10;
x2 = 0;
aaa = (x1*y1)+(y1)*(-x1*y1)/(y1-y2);
bbb = (x2*y2-x1*y1)/(y1-y2);
dist = 0:1/3:1600;
model = aaa./(dist + bbb);
legend('Coarse Approach','Fine Approach','Best Fit Line')
hp = plot(dist, model, 'r-', 'Linewidth', 1.5);
txt1 = ['V_{preamp} = ' num2str(aaa) ' / (Tool-Substrate Gap + (' num2str(bbb) '))'];
ht = text(580, 700, txt1, 'FontSize', 9);
for k = 2:352
y2=Mean(k);
x2=Mean(k);
aaa=(x1*y1)+(y1)*(x2*y2-x1*y1)/(y1-y2);
bbb=(x2*y2-x1*y1)/(y1-y2);
model = aaa./(dist + bbb);
hp.YData = model;
txt1 = ['V_{preamp} = ' num2str(aaa) ' / (Tool-Substrate Gap + (' num2str(bbb) '))'];
ht.String = txt1;
drawnow()
end

2 件のコメント

Walter Roberson
Walter Roberson 2019 年 4 月 11 日
Should only the current value be displayed, or do you want to leave everything up to that point on the line drawn (tracing out the path) ?
Hans123
Hans123 2019 年 4 月 11 日
Just the current value highlighted.

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

 採用された回答

Walter Roberson
Walter Roberson 2019 年 4 月 12 日

1 投票

Before the loop,
h = plot(nan, nan, 'yo', 'MarkerSize', 20, 'MarkerFaceColor, 'y'); %yellow, filled, large
Inside the loop,
set(h, 'XData', x_of_position_to_highlight, 'YData', y_of_position_to_highlight);

6 件のコメント

Hans123
Hans123 2019 年 4 月 13 日
sorry for the late response, work perfectly. Thank you so much really appreciate it!
Hans123
Hans123 2019 年 4 月 16 日
編集済み: Hans123 2019 年 4 月 16 日
This is a late follow-up question, but if I want to grey the part of the graph that the yellow dot has already gone through, how am I able to do it?
Would really appreciate any help.
Below I have attached what I am trying to achieve
Walter Roberson
Walter Roberson 2019 年 4 月 17 日
Remember when I asked about whether you wanted to leave a trail...
Hans123
Hans123 2019 年 4 月 17 日
yes, that is exactly what I wanted to do, I did not have foresight... I would like the trail to have a different color from the yellow dot (like gray)
Walter Roberson
Walter Roberson 2019 年 4 月 17 日
Create an animatedline with larger LineWidth and color gray and no marker, and do that before creating the handle for the yellow marker (so that the plot for the yellow marker is on "top" of the animated line.)
Each iteration,
addpoints(animated_line_handle, x_of_position_to_highlight, y_of_position_to_highlight)
do that as well as the set() that moves the highlight marker.
Hans123
Hans123 2019 年 4 月 17 日
you have no idea how much I appreciate your help!!!
Thank you

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

製品

タグ

質問済み:

2019 年 4 月 11 日

コメント済み:

2019 年 4 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by