フィルターのクリア

Why do I receive default error callback warning while running a loop?

17 ビュー (過去 30 日間)
Dru
Dru 2023 年 4 月 12 日
コメント済み: Dru 2023 年 4 月 12 日
I'm coding a loop that creates a plot with a moving animation. The animation has a pause function (line 64), and I get this warning every iteration of the loop. xdata and ydata are scalar values used to plot the point on the graph.
> In defaulterrorcallback (line 12)
In ActiveAnimation (line 64)
Warning: Error creating or updating Line
Error in value of one or more of the following properties: XData YData
Array is wrong shape or size

回答 (1 件)

Walter Roberson
Walter Roberson 2023 年 4 月 12 日
Your animation is extending XData by one (or more) points, and then extending YData by the same number of points, but as different operations. For example,
h = plot(1:10, 1:10)
h =
Line with properties: Color: [0 0.4470 0.7410] LineStyle: '-' LineWidth: 0.5000 Marker: 'none' MarkerSize: 6 MarkerFaceColor: 'none' XData: [1 2 3 4 5 6 7 8 9 10] YData: [1 2 3 4 5 6 7 8 9 10] Show all properties
h.XData(end+1) = 11
h =
Line with properties: Color: [0 0.4470 0.7410] LineStyle: '-' LineWidth: 0.5000 Marker: 'none' MarkerSize: 6 MarkerFaceColor: 'none' XData: [1 2 3 4 5 6 7 8 9 10 11] YData: [1 2 3 4 5 6 7 8 9 10] Show all properties
%XData is now 11 but YData is still 10
h.YData(end+1) = 11
h =
Line with properties: Color: [0 0.4470 0.7410] LineStyle: '-' LineWidth: 0.5000 Marker: 'none' MarkerSize: 6 MarkerFaceColor: 'none' XData: [1 2 3 4 5 6 7 8 9 10 11] YData: [1 2 3 4 5 6 7 8 9 10 11] Show all properties
Warning: Error creating or updating Line
Error in value of one or more of the following properties: XData YData
Array is wrong shape or size
%now they are the same length again
The warning shows up at rendering time.
There are two possible solutions:
  1. use set() to change the XData and YData calls in the same call; or
  2. use animatedline() and addpoints() which is designed for these kinds of situations
  1 件のコメント
Dru
Dru 2023 年 4 月 12 日
I was trying to use .set but was using it wrong. I figured it out now

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

カテゴリ

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

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by