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 &&.
  1 件のコメント
alize beemiel
alize beemiel 2020 年 11 月 30 日
thank u sir

サインインしてコメントする。


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 Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by