Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have searched, but didn't find much help on my issue. I have an optical physics problem that I'm working on ..

apeture = 1*10^-6;
r = Range[100];
k = Range[100];
λ = 632.8 * 10^-9;
pal = Pi*(apeture/λ);
θr = (r - 50)*(Pi/90);
field = Array[0 &, {k, r}];
Intensity = 1*(Sin[pal*Sin[θr]]/pal*Sin[θr])^2

admittedly I am a newcomer to Mathematica but not to programming. I operate mainly in embedded C but "speak" Python, Java, and Ada as well. So please understand that my question is mostly about using Mathematica.

What I need is a n x m matrix 100 entries square that the Intensity function maps onto down each row. When the matrix is populated, I create a copy of it, rotate it by pi/2 and add the two. Once done, I plot the result. This is to study the interference patterns of orthogonal single-slit diffraction (Mill's Cross effects).

An Edit for Clarity: Once the initial conditions are set, I need to place a function output in each row of the matrix. The columns are identical (at first). Then, I perform a 90 degree rotation of the matrix (CW or CCW.. doesn't matter as long as the results are orthogonal) and add the two. The resultant is an interference matrix that can be plotted.

My questions in this regard:

  1. Do I need to write a loop to do this, or can I write a compound statement like I have seen in other programs (MathCAD and MATLAB) that will automatically propagate the values in the matrix?
  2. After reading the various posts on matrix rotation, I'm not entirely convinced of the best method. Suggestions are appreciated.

Thanks for your help!

share|improve this question

closed as off-topic by rasher, bobthechemist, belisarius, gpap, Mr.Wizard Mar 26 at 10:50

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – rasher, bobthechemist, belisarius, gpap, Mr.Wizard
If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Some points: MMA uses square brackets [] to denote argument enclosure - you have parenthesis. If you mean to created field as a zero matrix of 100x100, you need {100,100} for the dimension argument, not the ranges in k and r. If the intent of the subscript use is to represent arrays, just use an array, subscript etc. is best used as a typographical/display effect. Lastly, seriously bad idea to use uppercase initials for symbols - quite likely you'll bang into MMA built-in names. –  rasher Mar 24 at 8:52
    
Thanks for the note about capitol letters, and the subscript was an artefact of copy-and-paste from MMA. I'll edit and fix that. The use of {k,r} was so that I could change the size of the field universally across the algorithm based on the number of measurements I'm supposed to be taking. –  willanth Mar 24 at 9:02
2  
I'm afraid your experience with procedural languages is hurting, not helping, your getting a grip on Mathematica. I have two pieces of advice. 1) Look up Table in the Documentation Center. It is Mathematica's high-level function for creating arrays of all kinds. It will run much faster than a loop. 2) Read this post. It was created to help new users like you. –  m_goldberg Mar 24 at 9:18

1 Answer 1

up vote 3 down vote accepted

You can use Outer for this:

result = Outer[Plus, Intensity, Intensity];

Image[Rescale[result]]

enter image description here

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.