how to find index of matrix

1 次查看(过去 30 天)
alize beemiel
alize beemiel 2020-11-29
编辑: dpb 2020-11-30
A=[1 8.5714 9.6250
2 8.5714 9.7500
3 8.5714 9.8750
4 8.5714 10.0000
5 8.7857 5.0000
6 8.7857 5.2500
7 8.7857 5.5000
8 8.7857 5.7500
9 8.7857 6.0000
10 8.7857 6.2500
11 8.7857 6.5000
12 8.7857 6.7500
13 8.7857 7.0000
14 8.7857 7.2500
15 8.7857 7.5000
16 8.7857 7.7500
17 8.7857 8.0000
18 8.7857 8.2500
19 8.7857 8.5000
20 8.7857 8.7500
21 8.7857 9.0000
22 8.7857 9.2500
23 8.7857 9.5000
24 8.7857 9.7500
25 8.7857 10.0000
26 9.0000 5.0000
27 9.0000 5.1250
28 9.0000 5.2500
29 9.0000 5.3750
30 9.0000 5.5000
31 9.0000 5.6250
32 9.0000 5.7500
33 9.0000 5.8750
34 9.0000 6.0000
35 9.0000 6.1250
36 9.0000 6.2500
37 9.0000 6.3750]
hi
I need to find the index of matrix A withe to have A=(:,1)=9 and A(:,2)=5.125
i try this
[row,col]=find (A(:,1)==9 && A(:,2)=5.125)
i need to have a sresult equal 27
  1 个评论
Mario Malic
Mario Malic 2020-11-29
See direction input argument in find, or try isequal and arrayfun

请先登录,再进行评论。

回答(2 个)

the cyclist
the cyclist 2020-11-30
It looks like you were checking the wrong columns.
row = find (A(:,2)==9 & A(:,3)==5.125)
Also, you need to use & rather than &&.

dpb
dpb 2020-11-30
编辑:dpb 2020-11-30
Try
[row,col]=find (A(:,1)==9 && A(:,3)=5.125)
You've got the column indices off --
If you really mean for it to be for A(:,2) then there is no solution in the above array.

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by