Vector Operation in Matlab? -


can body me explain line 7 of code. line

temp(min(temp,[],2) >=1 & max(temp,[],2)<=n,:) 

do in code?

line 7 of code throwing me off

 n=10;  h=-1;  j=0;  i=1:n      j=1:n          temp=[i-1,j;i+1,j;i,j-1;i,j+1];          ngh{i,j}=temp(min(temp,[],2) >=1 & max(temp,[],2)<=n,:);      end  end 

that line selecting rows of temp have values between 1 , n, , assigning submatrix ngh{i,j}.

note that

  • min(...,[],2) or max(...,[],2) gives minimum or maximum of each row;
  • the logical comparison 1 or n , & operation result in logical index vector, used address desired rows of temp (and columns).

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -