How to replace a pointer or marker with an object for tracing the desired path?
1 回表示 (過去 30 日間)
古いコメントを表示
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 ?
0 件のコメント
採用された回答
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
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!
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!