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