How to replace a pointer or marker with an object for tracing the desired path?

1 回表示 (過去 30 日間)
h b
h b 2017 年 1 月 23 日
編集済み: h b 2017 年 1 月 25 日
figure;
hold on
a=plot([10 10 5 5],[0 10 10 15],'r')
xlim([0 20])
ylim([0 20])
I want an object defined as blue rectangle with dimensions 0.5m*1m to trace the path given in the code.
How to do ?

採用された回答

Image Analyst
Image Analyst 2017 年 1 月 23 日
Use plot(), rectangle(), and pause(). Try this:
x = [10 10 5 5];
y = [0 10 10 15];
a=plot(x, y, 'r', 'LineWidth', 3)
xlim([0 20])
ylim([0 20])
xticks(0:20);
yticks(0:20);
grid on
hold on;
axis equal
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
yHeight = 0.5;
xWidth = 1;
for k = 1 : length(x)
xBoxLeft = x(k) - xWidth/2;
yBoxBottom = y(k) - yHeight/2;
hRect = rectangle('Position', [xBoxLeft, yBoxBottom, xWidth, yHeight], 'LineWidth', 2, 'EdgeColor', 'b');
pause(1);
delete(hRect);
end
  9 件のコメント
Image Analyst
Image Analyst 2017 年 1 月 24 日
You forgot to include your complete error message, so we can't see what string or other variable you're putting into the array. It must be numbers, not strings, structures, etc. Please show ALL THE RED TEXT not just part of it. You left out the crucial part - your line of code!
h b
h b 2017 年 1 月 25 日
編集済み: h b 2017 年 1 月 25 日
the error message :
Error using rectangle While setting property 'Position' of class 'Rectangle': Value must be numeric
Error in pointer14 (line 30) r=rectangle('Position', [x888(k1) y888(k1) 1 3], 'FaceColor','r');
(For the code mentioned in the comments)

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

その他の回答 (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