Draw Circle in matrix

  • Follow


How do yo draw a circle in a matrix with the value at 10V?? This is my set code so far, the circle should be to the left of the rectangle.

a=zeros(20,35);
a(:,1)=-5;
a(:,34)=5;
for kk=1:1000;
for ii=2:19;
for jj=2:34;
a(ii,jj)=1/4*(a(ii-1,jj)+a(ii+1,jj)+a(ii,jj-1)+a(ii,jj+1));
a(4:15,13:15)=-10;
end
end
end;
pcolor(a)
shading interp
0
Reply Jay 12/5/2010 11:20:08 PM

What do you mean by at the value 10?

First of all, you go through a useless loop over kk that just makes it
take 1000 times longer than it should.

Secondly, the values of a range from -10 to +5.  They never equal 10.
Repeat - they never ever equal +10.

Thirdly, you have the line
a(4:15,13:15)=-10;
nested way deep in the loop when it does not even need to be in the
loop AT ALL, since it doesn't depend on the loop variables.

And again, even if the value 10 *did* occur somewhere in your matrix
(say it's a rectangle or maybe some scattered elements around the
matrix), what does it mean to put a circle at the location with a
value of 10?  Do you want a circle of some (unspecified) radius
centered over every single pixel that has a radius of 10, so that if
you had 100 pixels with value 10, you'd have 100 circles?

Please take more time in accurately describing what you need.

0
Reply ImageAnalyst 12/5/2010 11:56:05 PM


I simply what to draw a circle in the set matrix, they are at a value since they represent an electromagnetic field , thanks
0
Reply Thomas 12/6/2010 12:14:05 AM

On Dec 5, 7:14=A0pm, "Thomas " <bj...@yahoo.com> wrote:
> I simply what to draw a circle in the set matrix, they are at a value sin=
ce they represent an electromagnetic field , thanks
---------------------------------------------------------------------------=
-----
Thomas:
Like the first poster, Jay, you are not being specific enough.
(1) Where in the matrix?  What is the center and what is the radius?
(2) I still don't know what you mean by "they are at a value".
Obviously elements in a matrix have values, but what does "they are at
a value" have to do with drawing a circle?
(3) Do you want a solid circle - a disc - or just the perimeter.
(4) Do you want the circle to appear in an overlay over your image, or
do you want the circle to actually be written into the pixel values
themselves, thus changing their original values?
(5) If you want the circle written into the image, what value would
you like the circle to have?
(6) If you want the circle to just appear in the overlay what color do
you want it to have?
(7) Have you searched the newsgroup?  Circle drawing comes up very
frequently.
(8) Have you looked at the rectangle function to draw a circle?

Please answer each question by number.
Why am I spending more time probing you about what you want to do than
you are explaining it?  Again I'll say "Please take more time in
accurately describing what you need. "  I'll give you two guys one
more shot at it before I bail out.
0
Reply ImageAnalyst 12/6/2010 12:48:26 AM

3 Replies
727 Views

(page loaded in 0.062 seconds)

Similiar Articles:













7/22/2012 10:16:38 AM


Reply: