creating circles for multiple points with viscircle

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?

Answers (3)

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 Comments

so I'm using this:
z4 = 10;
v4 = 0;
g = -9.81;
dt4 = 0.1;
t4 = [0:dt4:10];
zall4 = z4;
for time4 = 0:dt4:10
z4 = z4 + v4.*dt4 + (g.*dt4.^2)/2;
v4 = v4 + g.*dt4;
viscircles([time4,z4], 0.5);
if z4<=0
v4 = -v4;
end
end
This is drawing circles as I need them. Is this incorrect?
?? viscircles is not specifically meant for images ??
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.

Sign in to comment.

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

Categories

Tags

Asked:

on 27 Jan 2020

Commented:

on 27 Jan 2020

Community Treasure Hunt

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

Start Hunting!