由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Computation版 - 请教如何根据矩阵元素值找到矩阵的行号?
相关主题
问个矩阵生成Matlab逻辑运算符区别
请问怎样让一m长的向量和一mxn的矩阵相乘,仍为mxnMatlab 3D Matrix Operation Problem
[合集] 简单问题简单问,matlab问个MATLAB矩阵问题
[合集] Matlab 求助:如何把一个高维矩阵中的一维赋值给一个向量Matlab problem
请问matlab矩阵和向量对应元素相乘该怎么做?Matlab where function?
Matlab中计算特征值如何保持原始特征值顺序不变?MATLAB 并行计算问题
问个matlab的eigs的问题请帮忙一个矩阵处理的问题
在matlab中如果快速地求矩阵的逆请问怎么让m阶矩阵的每个元素减n阶矩阵的每个元素而不用for循环
相关话题的讨论汇总
话题: find话题: matlab话题: ismember话题: 矩阵话题: 行号
进入Computation版参与讨论
1 (共1页)
d*******2
发帖数: 340
1
比如4x3的矩阵,现有一向量a=[0 0 0]; 如何找到他的行号是第四行?先谢了!
0 0 20
0 5 10
4 9 4
0 0 0
r****x
发帖数: 3613
2
row = find(a==[c c c])

【在 d*******2 的大作中提到】
: 比如4x3的矩阵,现有一向量a=[0 0 0]; 如何找到他的行号是第四行?先谢了!
: 0 0 20
: 0 5 10
: 4 9 4
: 0 0 0

d*******2
发帖数: 340
3
>> a=[0 0 20; 0 5 10; 4 9 4; 0 0 0];
a =
0 0 20
0 5 10
4 9 4
0 0 0
>> row = find(a==[0 0 0])
??? Error using ==> eq
Matrix dimensions must agree.

【在 r****x 的大作中提到】
: row = find(a==[c c c])
r****x
发帖数: 3613
4
sorry, i tried the new one.
[row,col]=find(a==[0]);
for i=1:4
if a(i,1)==a(i,2) && a(i,1)==a(i,3) && a(i,1)==0
i
end
end
i =
4

【在 d*******2 的大作中提到】
: >> a=[0 0 20; 0 5 10; 4 9 4; 0 0 0];
: a =
: 0 0 20
: 0 5 10
: 4 9 4
: 0 0 0
: >> row = find(a==[0 0 0])
: ??? Error using ==> eq
: Matrix dimensions must agree.

r****x
发帖数: 3613
5
i can't find any simple pre designed matlab functions.

【在 r****x 的大作中提到】
: sorry, i tried the new one.
: [row,col]=find(a==[0]);
: for i=1:4
: if a(i,1)==a(i,2) && a(i,1)==a(i,3) && a(i,1)==0
: i
: end
: end
: i =
: 4

t***s
发帖数: 4666
6
find(ismember(A,a,'rows'))

【在 d*******2 的大作中提到】
: 比如4x3的矩阵,现有一向量a=[0 0 0]; 如何找到他的行号是第四行?先谢了!
: 0 0 20
: 0 5 10
: 4 9 4
: 0 0 0

d*******2
发帖数: 340
7
Thank you very much and admire you very much!

【在 t***s 的大作中提到】
: find(ismember(A,a,'rows'))
j****x
发帖数: 943
8
Just curious, isn't "find" pretty slow? any other alternatives? Only for
matlab or using python?
i******t
发帖数: 370
9
This code is more efficient though harder to read:
e = A-repmat(a, [size(A, 1), 1]);
i = find(sum(e==0, 2)==size(A, 2));
"find" only operates on a vector so it's fast.

【在 j****x 的大作中提到】
: Just curious, isn't "find" pretty slow? any other alternatives? Only for
: matlab or using python?

b****r
发帖数: 5889
10
那这样会快点吗
find(ismember(A',a','column'))

【在 i******t 的大作中提到】
: This code is more efficient though harder to read:
: e = A-repmat(a, [size(A, 1), 1]);
: i = find(sum(e==0, 2)==size(A, 2));
: "find" only operates on a vector so it's fast.

相关主题
Matlab中计算特征值如何保持原始特征值顺序不变?Matlab逻辑运算符区别
问个matlab的eigs的问题Matlab 3D Matrix Operation Problem
在matlab中如果快速地求矩阵的逆问个MATLAB矩阵问题
进入Computation版参与讨论
t***s
发帖数: 4666
11
find(ismember()) operates on a vector too. hehe.
i don't know how ismember is implemented.

【在 i******t 的大作中提到】
: This code is more efficient though harder to read:
: e = A-repmat(a, [size(A, 1), 1]);
: i = find(sum(e==0, 2)==size(A, 2));
: "find" only operates on a vector so it's fast.

c****w
发帖数: 565
12
naive to argue about function speed under MATLAB, if you want speed, forget
about MATLAB
g****y
发帖数: 199
13
even for Matlab, high speed is always better, and those discussions are also
helpful. don't be too picky:)

forget

【在 c****w 的大作中提到】
: naive to argue about function speed under MATLAB, if you want speed, forget
: about MATLAB

i******t
发帖数: 370
14
The speed matters.
If you have a matlab code written in 3 recursive loops with 100 iterations
each, you will need to optimize the code...

forget

【在 c****w 的大作中提到】
: naive to argue about function speed under MATLAB, if you want speed, forget
: about MATLAB

d*******2
发帖数: 340
15
I guess 99% of people who complain matlab's speed are not using matlab
properly, although you might be the rest 1%.

forget

【在 c****w 的大作中提到】
: naive to argue about function speed under MATLAB, if you want speed, forget
: about MATLAB

p*****o
发帖数: 40
16
er...

【在 d*******2 的大作中提到】
: I guess 99% of people who complain matlab's speed are not using matlab
: properly, although you might be the rest 1%.
:
: forget

1 (共1页)
进入Computation版参与讨论
相关主题
请问怎么让m阶矩阵的每个元素减n阶矩阵的每个元素而不用for循环请问matlab矩阵和向量对应元素相乘该怎么做?
[合集] 怎么产生这个矩阵?Matlab中计算特征值如何保持原始特征值顺序不变?
问个matlab的matrix问题问个matlab的eigs的问题
请问一下关于input2=input(input~=0)的用法在matlab中如果快速地求矩阵的逆
问个矩阵生成Matlab逻辑运算符区别
请问怎样让一m长的向量和一mxn的矩阵相乘,仍为mxnMatlab 3D Matrix Operation Problem
[合集] 简单问题简单问,matlab问个MATLAB矩阵问题
[合集] Matlab 求助:如何把一个高维矩阵中的一维赋值给一个向量Matlab problem
相关话题的讨论汇总
话题: find话题: matlab话题: ismember话题: 矩阵话题: 行号