MATLAB: Matlab function to take matrix as input and return elements in its four corners as output

matrix and functions

Hello, good day all, please I'm having difficulties writing a function to take a matrix input, and return the elements in its cour corners as an output.
Here is my code:
function [top_left,top_right,bottom_left,bottom_right] = corners(i,r,c)
A = matrix(i,r,c)
top_left = A(1,1);
top_right = A(1,c);
bottom_left = A(r,1);
bottom_right = A(r,c);
function B = matrix(i,r,c)
ind = i;
row = r;
col = c;
B = randi(ind,row,col);
I keep getting Not enough input arguments.
Error in corners (line 2)
A = matrix(i,r,c)
I'll appreciate your response. Thanks.

Best Answer

Maybe this is what you really want:
function Acorners = corners(A)
Acorners=A([1,end],[1,end]);
end
Related Question