I believe this is what you are after.
FAIR WARNING:
- i haven't run thus code
- i had never even heard of MATLAB before reading this question
public IDictionary<Point, double> gaborFn(double sigma, double theta, double lambda, double psi, double gamma)
{
IDictionary<Point,double> result = new Dictionary<Point,double> ();
double sigma_x = sigma;
double sigma_y = sigma/gamma;
int nstds = 3;
double xmax = Math.Max(Math.Abs(nstds*sigma_x*Math.Cos(theta)),Math.Abs(nstds*sigma_y*Math.Sin(theta)));
xmax = Math.Ceiling(Math.Max(1,xmax));
double ymax = Math.Max(Math.Abs(nstds*sigma_x*Math.Sin(theta)),Math.Abs(nstds*sigma_y*Math.Cos(theta)));
ymax = Math.Ceiling(Math.Max(1,ymax));
double xmin = -xmax;
double ymin = -ymax;
for (int x = (int)xmin; x <=xmax;x++)
{
for (int y = (int)ymin; x <= ymax; x++)
{
double x_theta = x * Math.Cos(theta) + y * Math.Sin(theta);
double y_theta = -x * Math.Sin(theta) + y * Math.Cos(theta);
double gb = 1 / (2 * Math.PI * sigma_x * sigma_y) * Math.Exp(-.5 * (Math.Pow(x_theta, 2) / Math.Pow(sigma_x, 2) + Math.Pow(y_theta, 2) / Math.Pow(sigma_y, 2))) * Math.Cos(2 * Math.PI / lambda * x_theta + psi);
result.Add(new Point(x, y), gb);
}
}
return result;
}