How to debug "Value must be a handle" error.

For some expressions of x_k, y_k, E_k, why the error "Value must be a handle" is copming for the follwing code:
figure(1)
sub1=subplot(2,1,1);
ani1 = animatedline('Color','r');
sub2 = subplot(2,1,2);
ani2 = animatedline('Color','k');
for k=1:length(t)
t_k = t(k);
x_k = x(k);
y_k = y(k);
E_k = E(k);
plot(x_k, y_k,'go','LineWidth',1.5,'MarkerSize',2)
hold on
title(['Time=',num2str(k*0.01)]);
addpoints(ani1,x,y);
plot(t_k, E_k,'go','LineWidth',1.5,'MarkerSize',2)
hold on
addpoints(ani2,t, E(1:end-1));
drawnow
end
Can anyone plz help?

3 件のコメント

Adam Danz
Adam Danz 2023 年 1 月 9 日
Please share the entire copy-pasted error message so we can get a bit more info. Specifically, what line is causing this error? I don't see any unexpected arguments that should be handles upon a quick glance.
A common culprit is when a the user has a file on path that matches the name of a MATLAB file but has a different set of input arguments. Using which(__,'all') is helpful for identifying those issues.
Pallov Anand
Pallov Anand 2023 年 1 月 9 日
Error using matlab.graphics.animation.AnimatedLine/addpoints
Value must be a handle.
Error in desiredpoint (line 106)
addpoints(ani2,t, E(1:end-1));
Adam Danz
Adam Danz 2023 年 1 月 9 日
Thanks, please fill in your MATLAB Release info on the right column of this page or share it here.

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

質問済み:

2023 年 1 月 9 日

コメント済み:

2023 年 1 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by