creating circles for multiple points with viscircle

20 ビュー (過去 30 日間)
Aaron Kurlantzick
Aaron Kurlantzick 2020 年 1 月 27 日
コメント済み: Image Analyst 2020 年 1 月 27 日
I have some time points in variable t and some position values in variable z, and want to make circles of radius 0.5 at those points using viscircles. How would I set that up?

回答 (3 件)

Walter Roberson
Walter Roberson 2020 年 1 月 27 日
viscircles([t(:), z(:)], 0.5)

Image Analyst
Image Analyst 2020 年 1 月 27 日
viscircles() is meant for images. I'm not sure that you have an image. You seem to have a time signal and a z signal. You just want plot()
t = 1 : 20;
z = rand(size(t));
plot(t, z, 'bo-', 'MarkerSize', 20, 'LineWidth', 1);
grid on;
xlabel('Time', 'FontSize', 15);
ylabel('Z', 'FontSize', 15);
title('Z vs. Time', 'FontSize', 15);
Vary the marker size until you get the look you desire.
0000 Screenshot.png
  3 件のコメント
Walter Roberson
Walter Roberson 2020 年 1 月 27 日
?? viscircles is not specifically meant for images ??
Image Analyst
Image Analyst 2020 年 1 月 27 日
If it does what you want then that's fine. viscircles() is part of the Image Processing Toolbox, though it appears it can also be used on an axes without an image in it. However the radius of 0.5 can apply to the z direction only. It will still be a circle, but the width in the time direction won't be a distance, it will be a time.

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


Adam Danz
Adam Danz 2020 年 1 月 27 日
編集済み: Adam Danz 2020 年 1 月 27 日
To plot a set of circles defined by their center points and a radius, you can use the the rectangel function with 100% curvature.
Here's a demo.
% Define (x,y) centers
circleCenters = [
1.0 2.5
1.5 3.0
2.1 1.1
3.0 2.5];
% Define radius
r = 0.5;
% create rounded rectangles (ie, circles) for
% each center point. The rectangle is defined
% by its lower, left corner so the circle
% centers need shifted have 1/2 the radius.
lowerLeft = circleCenters - r/2;
% plot the rectangles
clf()
cla()
hold on % important
arrayfun(@(i)rectangle('Position',[lowerLeft(i,:),r,r],...
'Curvature',[1,1]), 1:size(lowerLeft,1));
axis equal % so circles appear circular
% add circle centers
plot(circleCenters(:,1),circleCenters(:,2),'rx')
If you'd rather use viscircles on those data,
% or this method
cla()
viscircles(circleCenters,repmat(r,size(circleCenters,1),1));
axis equal

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by