MATLAB: I want to apply what the norm function does, without using norm.

circlefunctionhigher levelnorm

I am trying to write a code with some overlapping circles. I have written a code that works using the norm function, however, I want as little 'higher-level' functions as possible. Is there a way to do this?
I have the following piece of code that runs:
if norm(center(n,:)-[row col])<= radius
circle_pattern(col,row,n) = 1;
end
And when I replace it with this code (I tried to do some research on norm), my code will not plot the same image.
if ((center(n,:)-row).^2 + (center(n,:)-col).^2) <= radius
circle_pattern(col,row,n) = 1;
end
Any ideas on how to fix this?

Best Answer

Since this seems to be homework, if you don't want to use canned code, I will ask you to think on your own a bit.
At the same time, for whatever reason you have chosen to not use norm here, NOT using canned code written by experts in the field is a BAD idea. You may think that you are being self sufficient. That is NOT a good idea here. Your hand written code will be often less than optimal. It will be less efficient, but often it may have subtle bugs in it that you won't even know exist. WHEREVER possible, use all the tools you have given to you. If you choose to let pride get in your way, your code will be the poorer for it.
In fact, even something as simple as norm had something in there as I recall to fix some problem that can arise, though I seem to recall it having to do with de-normalized numbers.
Anyway, a hint: A norm will have a square root in there, no? So the 2-norm will be the sqrt of the sum of squares.
Or, you can compare what you did compute to radius^2.