creating circles for multiple points with viscircle

31 次查看(过去 30 天)
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 个评论
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