code: function() {
          var matrix;
          if (!this.matrixIds || this.matrixIds.length === 0) {
              matrix = {identifier: this.getIdentifier()};
          } else {
              // get appropriate matrix given the map scale if possible
              if ("scaleDenominator" in this.matrixIds[0]) {
                  // scale denominator calculation based on WMTS spec
                  var denom = 
                      OpenLayers.METERS_PER_INCH * 
                      OpenLayers.INCHES_PER_UNIT[this.units] * 
                      this.getServerResolution() / 0.28E-3;
                  var diff = Number.POSITIVE_INFINITY;
                  var delta;
                  for (var i=0, ii=this.matrixIds.length; i<ii; ++i) {
                      delta = Math.abs(1 - (this.matrixIds[i].scaleDenominator / denom));
                      if (delta < diff) {
                          diff = delta;
                          matrix = this.matrixIds[i];
                      }
                  }
              } else {
                  // fall back on zoom as index
                  matrix = this.matrixIds[this.getIdentifier()];
              }
          }
          return matrix;
      }
docs: Method: getMatrix
  Get the appropriate matrix definition for the current map resolution.