フィルターのクリア

How to move a marker on a figure?

9 ビュー (過去 30 日間)
Dru
Dru 2023 年 4 月 12 日
コメント済み: Dru 2023 年 4 月 12 日
I am trying to make an animation that moves a marker in a circle. I'm having trouble with moving the marker. This is my setup statement
markerhandle = plot(xdata, ydata, 'k.', 'MarkerSize', 36);
This is my statement to move the marker
markerhandle.set('xdata', 'ydata', ...
'Marker', 'k.', ...
'MarkerFaceColor', 'r', ...
'MarkerEdgeColor', 'r', ...
'MarkerSize', 36);
The second statement returns errors, however, I can make it kinda work by doing markerhandle = plot(ect...). This leaves all of the old markers in the figure and I only want one marker.
  2 件のコメント
Dru
Dru 2023 年 4 月 12 日
編集済み: Dru 2023 年 4 月 12 日
With this line of code
markerhandle.set(xdata, ydata, ...
'Marker', '.', ...
'MarkerFaceColor', 'k', ...
'MarkerEdgeColor', 'k', ...
'MarkerSize', 36);
I recieved this error
Error using matlab.graphics.chart.primitive.Line/set
Invalid parameter/value pair arguments.
Error in ActiveAnimation (line 51)
markerhandle.set(xdata, ydata, ...
Dru
Dru 2023 年 4 月 12 日
Updated code that works as expected
markerhandle.set('Xdata', xdata, 'Ydata', ydata, ...
'Marker', '.', ...
'MarkerFaceColor', 'k', ...
'MarkerEdgeColor', 'k', ...
'MarkerSize', 36);

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

採用された回答

Daniel
Daniel 2023 年 4 月 12 日
There appear to be two problems:
  1. 'XData' and 'YData' have to be followed by the actual xdata and ydata for the new point.
  2. Since you specify the marker color separately in this syntax, the 'Marker' value should be '.' rather than 'k.'.
By the way, if you type 'doc markerhandle.set' into the command window after markerhandle is created, it pulls up the line properties, which will help you sort through how each name/value pair should be defined.
  1 件のコメント
Dru
Dru 2023 年 4 月 12 日
If xdata and ydata are my variable names do I just remove the quotation marks?

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by