Matlab - Matrix Function with an Independent Variable?

I'm trying create a function that returns a matrix containing a variable "l" which is an independent variable to be swept for a plot later on.

I would calculate "phi" based on user inputs which include "n" and "d", then I would use "n", "d", and "phi" to find "a", "b", "c", and "d" to create a matrix "m" with. This matrix "m" will be a function of "l".

phi = 2*pi*n*d/l;
a = cos(phi);
b = 1i*sin(phi)/n;
c = 1i*n*sin(phi);
d = cos(phi);
m = [a b;c d];


I'm really not enjoying Matlab's coding style as compared to C++ and Python... How would you guys implement this functionality?

Summary: I want a function that returns a matrix which contains an independent variable to be swept for a plot later.

-
This question may be better suited for stackoverflow. – Michael Ulm Feb 4 '11 at 7:57
Okay, I'll try over there. – user6605 Feb 4 '11 at 16:41

Just to clearing out of the unanswered list!

You can define either a handle with @ or you can wrap up what you did as a function simply by

function [ mout ] = m_of_l( lin )
phi = 2*pi*n*d/lin ;
mout = [cos(phi) 1i*sin(phi)/n;1i*n*sin(phi) cos(phi)];
end


Later, you can use M = m_of_l(2*pi) to evaluate it at $l=2\pi$.

-