Thread Subject: Circular aperture

Subject: Circular aperture

From: T Matheson Matheson

Date: 4 Jul, 2008 12:47:02

Message: 1 of 3

Hi,

I am trying to create a circular matrix of ones within a
matrix of zeros. The reason being, I'm trying to simulate
fraunhofer diffraction by using the fft2 algorithm within
matlab (2 dimensional fourier transform) of a circular
aperture.

I have tried using the fspecial('disk', radius) matlab
utility but have been unable to get it to be exactly in the
centre of a matrix of zeros.

So my question is, does anyone know how to construct a
matrix of ones in the middle of a matrix of zeros, or, do
they know how to use the fspecial utility such that i can
shift it too the middle? (i've tried fftshift but it does
not quite shift it to the middle).

Thanks for your time,

T

Subject: Circular aperture

From: Jos

Date: 4 Jul, 2008 14:46:01

Message: 2 of 3

"T Matheson Matheson" <duvorap@hotmail.com> wrote in
message <g4l645$l2k$1@fred.mathworks.com>...
> Hi,
>
> I am trying to create a circular matrix of ones within a
> matrix of zeros. The reason being, I'm trying to simulate
> fraunhofer diffraction by using the fft2 algorithm within
> matlab (2 dimensional fourier transform) of a circular
> aperture.
>
> I have tried using the fspecial('disk', radius) matlab
> utility but have been unable to get it to be exactly in
the
> centre of a matrix of zeros.
>
> So my question is, does anyone know how to construct a
> matrix of ones in the middle of a matrix of zeros, or, do
> they know how to use the fspecial utility such that i can
> shift it too the middle? (i've tried fftshift but it does
> not quite shift it to the middle).
>
> Thanks for your time,
>
> T


If I understand your problem correctly, this may get you
started:

n = 51 ; % size of matrix, odd
R = 12 ; % radius
n2 = floor(n/2) ;
[x,y] = meshgrid(-n2:n2) ;
M = sqrt(x.^2 + y.^2) < R ;

M = double(M) ; % convert from logical to double
imshow(M)

hth
Jos



Subject: Circular aperture

From: T Matheson

Date: 4 Jul, 2008 22:18:02

Message: 3 of 3

Thank you Jos, this is exactly what I wanted. I see I
still have alot to learn about Matlab!

Thanks again,

T

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
diffraction apeture George 8 Sep, 2008 19:51:44
rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com