function nbyn = bottom_left(N,n)
%Input a matrix N and a scalar n, each dimension of N is greater than or equal to n
%Output nbyn square array at the bottom left corner of N
%Example:
% N = [1 2 3;4 5 6;7 8 9]
% nbyn=bottom_left(N, 2)
[x,y] = size(N); %row and columns of N
if n<=max(x,y) %condition check
nbyn = N(x-n+1:x,1:n); %bottom left matrix of size nxn
end
Search Program on this blog
Tuesday, 18 August 2015
Write a function called bottom_left that takes two inputs: a matrix N and a scalar n, in that order, where each dimension of N is greater than or equal to n. The function returns the n-by-n square array at the bottom left corner of N.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment