matlab中find函数参数代表什么意思?我看过help,但有些不懂.看下面代码,请指教X =3 2 0-5 0 70 0 1 [r,c,v] = find(X>2)returns a vector of row indices of the nonzero entries of N where N=(X>2)r =12a vector of column indices of the
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/13 03:09:58
![matlab中find函数参数代表什么意思?我看过help,但有些不懂.看下面代码,请指教X =3 2 0-5 0 70 0 1 [r,c,v] = find(X>2)returns a vector of row indices of the nonzero entries of N where N=(X>2)r =12a vector of column indices of the](/uploads/image/z/6920894-38-4.jpg?t=matlab%E4%B8%ADfind%E5%87%BD%E6%95%B0%E5%8F%82%E6%95%B0%E4%BB%A3%E8%A1%A8%E4%BB%80%E4%B9%88%E6%84%8F%E6%80%9D%3F%E6%88%91%E7%9C%8B%E8%BF%87help%2C%E4%BD%86%E6%9C%89%E4%BA%9B%E4%B8%8D%E6%87%82.%E7%9C%8B%E4%B8%8B%E9%9D%A2%E4%BB%A3%E7%A0%81%2C%E8%AF%B7%E6%8C%87%E6%95%99X+%3D3+2+0-5+0+70+0+1+%5Br%2Cc%2Cv%5D+%3D+find%28X%3E2%29returns+a+vector+of+row+indices+of+the+nonzero+entries+of+N+where+N%3D%28X%3E2%29r+%3D12a+vector+of+column+indices+of+the)
matlab中find函数参数代表什么意思?我看过help,但有些不懂.看下面代码,请指教X =3 2 0-5 0 70 0 1 [r,c,v] = find(X>2)returns a vector of row indices of the nonzero entries of N where N=(X>2)r =12a vector of column indices of the
matlab中find函数参数代表什么意思?
我看过help,但有些不懂.看下面代码,请指教
X =
3 2 0
-5 0 7
0 0 1
[r,c,v] = find(X>2)
returns a vector of row indices of the nonzero entries of N where N=(X>2)
r =
1
2
a vector of column indices of the nonzero entries of N where N=(X>2)
c =
1
3
and a logical array that contains the nonzero elements of N where N=(X>2).
v =
1
1
matlab中find函数参数代表什么意思?我看过help,但有些不懂.看下面代码,请指教X =3 2 0-5 0 70 0 1 [r,c,v] = find(X>2)returns a vector of row indices of the nonzero entries of N where N=(X>2)r =12a vector of column indices of the
[r,c,v]=find(A),找到矩阵A中不为0的元素并返回
r找到的行,v找到的列,不为0元素的值
例如你用[r c v]=find([3 0;0 4]);
也就是矩阵|3 0|,从中找不为0的数,就会返回
|0 4|
r =
1
2
c =
1
2
v =
3
4
其中r c v的长度相等,一一对应表示
找到非零元素是 1行1列的3,而2行2列的4
然而通常多数用find来需找符合逻辑判断条件的元素的下标
其实,这个时候是分开两部来做的
首先逻辑判断条件实际上是一个表达式,可以返回一个逻辑矩阵
返回的矩阵中对应原来符合逻辑条件的元素的位置就会是1,不符合条件的就是0
你可以试一下 刚才的矩阵
X=[3 0;0 4];
X>2
ans =
1 0
0 1
返回的矩阵中符合条件大于2的位置是1,不符合的位置是0
然后我们再用find去寻找时r,c返回了不为0的元素的行列位置,而v返回的值就都是1了
由于通常我们用find函数多是find一个逻辑表达式,也就是不是0就是1的矩阵
所以的到的v都是1,平常我们就没有必要反会它了
但是实际上find是找所有非零元素的,如果有一天你需要得到矩阵中多有非零元素的值
的时候,别忘了可以利用这个返回的v