MATLAB expression column indexing

indexing, matlab

Solution

I have a function like this in my path:

getRegion = @(matrix, rows, cols) matrix(rows,cols);

So that I can then call:

getRegion(cov(M), 1, 1);

It would also work if you wanted a larger region:

getRegion(cov(M), 1:2, 2);

Problem

I have an expression that gives a matrix and I want to access an element, without creating a temporary variable, something like this `cov(M)(1,1)`. How can I do it? Thanks!

Original source