MATLAB Answers

how to find index of matrix

4 views (last 30 days)
alize beemiel
alize beemiel on 29 Nov 2020
Edited: dpb on 30 Nov 2020
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 Comment

Mario Malic
Mario Malic on 29 Nov 2020
See direction input argument in find, or try isequal and arrayfun

Sign in to comment.

Answers (2)

the cyclist
the cyclist on 30 Nov 2020
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 Comment

Sign in to comment.


dpb
dpb on 30 Nov 2020
Edited: dpb on 30 Nov 2020
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.

  0 Comments

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by