# Thread: Plotting multiple circles in Octave from arrays

1. ## Plotting multiple circles in Octave from arrays

Hi,

I've basically exhausted myself trying to use Octave to plot a number of circles on the same graph. I've written code in C that outputs a file with three columns:

1) x coordinate of centre of circle
2) y coordinate of centre of circle

There are approximately 30~35 circles to be plotted in each graph.

For example, the file might read in:

0 0.125000 0.125000 0.050000
1 0.050000 0.300000 0.050000
2 0.375000 0.125000 0.125000
3 0.050000 0.400000 0.050000
4 0.375000 0.375000 0.125000
5 0.125000 0.575000 0.125000
6 0.050000 0.750000 0.050000
7 0.150000 0.300000 0.050000
8 0.375000 0.625000 0.125000
9 0.625000 0.125000 0.050000
10 0.375000 0.875000 0.125000
11 0.150000 0.400000 0.125000
12 0.625000 0.375000 0.050000
13 0.150000 0.750000 0.050000
14 0.625000 0.625000 0.125000
15 0.875000 0.375000 0.125000
16 0.625000 0.875000 0.125000
17 0.050000 0.850000 0.125000
18 0.875000 0.875000 0.125000
19 0.875000 0.625000 0.125000
20 0.875000 0.125000 0.050000
22 0.150000 0.850000 0.050000
23 0.050000 0.950000 0.050000
26 0.250000 0.750000 0.050000
28 0.150000 0.950000 0.050000

Thing is, I need to do this for a variety of different parameters.

I know that in order to plot it implicitly i need something like:

t=0.01:0.01:2*pi

x = sqrt(r)*cos(t)+x_0
y = sqrt(r)*cos(t)+y_0

but the problem comes when defining x,y and then plotting them. Argh! Can anyone please help me write a little script to plot all these on the same graph please? I'd be forever indebted.

RH

2. Originally Posted by redherring
Hi,

I've basically exhausted myself trying to use Octave to plot a number of circles on the same graph. I've written code in C that outputs a file with three columns:

1) x coordinate of centre of circle
2) y coordinate of centre of circle

There are approximately 30~35 circles to be plotted in each graph.

For example, the file might read in:

0 0.125000 0.125000 0.050000
1 0.050000 0.300000 0.050000
2 0.375000 0.125000 0.125000
3 0.050000 0.400000 0.050000
4 0.375000 0.375000 0.125000
5 0.125000 0.575000 0.125000
6 0.050000 0.750000 0.050000
7 0.150000 0.300000 0.050000
8 0.375000 0.625000 0.125000
9 0.625000 0.125000 0.050000
10 0.375000 0.875000 0.125000
11 0.150000 0.400000 0.125000
12 0.625000 0.375000 0.050000
13 0.150000 0.750000 0.050000
14 0.625000 0.625000 0.125000
15 0.875000 0.375000 0.125000
16 0.625000 0.875000 0.125000
17 0.050000 0.850000 0.125000
18 0.875000 0.875000 0.125000
19 0.875000 0.625000 0.125000
20 0.875000 0.125000 0.050000
22 0.150000 0.850000 0.050000
23 0.050000 0.950000 0.050000
26 0.250000 0.750000 0.050000
28 0.150000 0.950000 0.050000

Thing is, I need to do this for a variety of different parameters.

I know that in order to plot it implicitly i need something like:

t=0.01:0.01:2*pi

x = sqrt(r)*cos(t)+x_0
y = sqrt(r)*cos(t)+y_0

but the problem comes when defining x,y and then plotting them. Argh! Can anyone please help me write a little script to plot all these on the same graph please? I'd be forever indebted.

RH
For starters

x=r*cos(t)+x0
y=r*sin(t)+x0

plot(x,y)

CB