"Index exceeds matrix dimensions" Error. solution please.

6 ビュー (過去 30 日間)
h b
h b 2016 年 11 月 4 日
コメント済み: h b 2016 年 11 月 11 日
x1=60;x2=40; y1=40; y2=60;
d = sqrt((x2-x1)^2+(y2-y1)^2);
a = atan2(-(x2-x1),(y2-y1));
b = asin(d/2/r);
c = linspace(a-b,a+b);
e = sqrt(r^2-d^2/4);
x = (x1+x2)/2-e*cos(a)+r*cos(c);
y = (y1+y2)/2-e*sin(a)+r*sin(c);
axis([0 150 0 150])
hold on
plot(x,y,'r');
axis([0 150 0 150])
h1 = plot(x(1),y(1),'bs','MarkerSize',7,'MarkerFaceColor','r');
for n = 1:numel(t)
set(h1, 'XData', x(n), 'YData', y(n)); %HERE
drawnow %// refresh figure
end
The error is displayed in the highlighted line.
suggest solution. (what should be the value of t here)
Here, the program runs even without specifying the value of t. how is it possible?
Can the speed of the pointer be controlled (in terms of frequency/velocity) by the user given input (from dialog box)?
  1 件のコメント
Jan
Jan 2016 年 11 月 4 日
@h b: Please format your code using the "{} code" button. It is easier to help you, when the code is readable.

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

採用された回答

Walter Roberson
Walter Roberson 2016 年 11 月 4 日
You have an old t variable sitting around or passed in,and it is longer than your x is.
  14 件のコメント
Walter Roberson
Walter Roberson 2016 年 11 月 11 日
Forgot, sorry.
h b
h b 2016 年 11 月 11 日
Thank you so much.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by