MATLAB Operation Speciale.

Matlab中的一些骚操作:

assuming that we have a matrix mat, which is defined as such:

mat = [1,2,3,4; 5,4,2,1]; which is:
1 2 3 4
5 4 2 1

(1) then if we wanna find the occurannces of the number “2” then:
occr = sum(sum(mat==2))

(2) batch operation, which is the reason that I chose MATLAB for projects.
mat(mat==1) = mat(mat==1) + 2;
the matrix will become:
3 2 3 4
5 4 2 3

发表评论

电子邮件地址不会被公开。 必填项已用*标注