Changing dimensions of matrix
2 views (last 30 days)
Say that we have two matrices.One is a 32*15 matrix and the other is 66*31 matrix.It is required to determine where this(32,15) matrix is located on the (66,31) matrix. Then you get the 3rd matrix with of size (66,31) with values known at the (32,15) positions.Then how do I fill the matrix with interp2
See attached demo for normxcorr2() where you can find a template matrix inside a larger matrix.
Here's one way using isequal().
% Create sample data
bigMatrix = randi(9, 66, 31)
% Get smaller 32*15 matrix from location 3,5, so we'll know it definitely exists in bigMatrix.
smallMatrix = bigMatrix(3:34, 5:19)
% Now find small amtrix in big matrix
for col = 1 : 17
for row = 1 : 35
subMatrix = bigMatrix(row:row+31, col:col+14);
if isequal(subMatrix, smallMatrix)
message = sprintf('Small matrix found in large matrix at location row=%d, col = %d', row, col);
If you know the match occurs only once, you can put a "break;" after the uiwait().