\name{InsertDim}
\alias{InsertDim}
\title{
  Adds A Dimension To A Matrix
}
\description{
  Add one dimension to the matrix var in position posdim with length lendim 
  and which correspond to lendim repetitions of the var matrix.
}
\usage{
  InsertDim(var, posdim, lendim)
}
\arguments{
  \item{var}{
    Matrix to which a dimension should be added.
  }
  \item{posdim}{
    Position of the new dimension.
  }
  \item{lendim}{
    Length of the new dimension.
  }
}
\value{
  Matrix with the added dimension.
}
\examples{
  startDates <- c('19901101', '19951101', '20001101')
  sampleData <- Load('tos', c('i00k'), c('ERSST'),  startDates,
                     nleadtime = 124, leadtimemin = 1, leadtimemax = 60, 
                     sampleperiod = 3, output = 'lonlat', latmin = -60,
                     latmax = 65, lonmin = 315, lonmax = 360)
  data_mod_1990 <- InsertDim(InsertDim(sampleData$mod[ , , 1, , , ], 2, 1), 1, 1)
}
\author{
  History:
  0.1  -  2011-03  (V. Guemas, \email{virginie.guemas@ic3.cat})  -  Original code
  1.0  -  2013-09  (N. Manubens, \email{nicolau.manubens@ic3.cat})  -  Formatting to R CRAN
}
\keyword{datagen}
