Having the next code:
function m=submatrix(k,N) %% returns submatrix where k is placed %% N => NxN matrix n=sqrt(N); %% create submatrix of nx n elements with different number in order to identify them aa=[]; aa=kron(1:n,ones(n,n)); b=aa; for i=1:n-1 b=[b;aa+n*i]; end vv=b(k); m=find(b==vv);end
These are my input parameters:
N = [1 4 3 2; 3 2 4 1; 4 1 2 3; 2 3 1 4]; k = 1;
k = 1 would be 1×1 = 1
k = 5 would be 1×2 = 4
I keep getting an error in line 7: aa=kron(1:n,ones(n,n)), and I'm totally clueless; I tried modifying kron values with similars but I keep getting that.
Best Answer