how we find a particular number from the matrix in matlab????

46 ビュー (過去 30 日間)
prema13
prema13 2015 年 10 月 4 日
編集済み: Stephen23 2015 年 10 月 19 日
A=[2 3 4;5 4 6;7 8 4] suppose we want to select '4' of 1st row of 3rd column,2nd row of 2nd column and 3rd row of 3rd column.how did we find this number?????

採用された回答

Stephen23
Stephen23 2015 年 10 月 4 日
編集済み: Stephen23 2015 年 10 月 4 日
It is not clear what numbers you want: when you write that you want "this number", are you referring to the indices of the fours in that matrix, or the fours themselves, or perhaps some other numbers? If you don't tell us exactly what you want, or what you need to do with these numbers, then it is difficult for us to provide you with a clear answer.
It seems that you want the indices of the fours, in which case here are some possible ways to get indices of values in a matrix:
>> A=[2 3 4;5 4 6;7 8 4] % data matrix
A =
2 3 4
5 4 6
7 8 4
>> [R,C] = find(A==4) % row and column indices
R =
2
1
3
C =
2
3
3
>> L = find(A==4) % linear indices
L =
5
7
9
>> X = A==4 % logical indices
X =
0 0 1
0 1 0
0 0 1
And of course you can use any of these to extract those value from the matrix:
>> A(X)
ans =
4
4
4
You can read more about indexing in the documentation:
  8 件のコメント
prema13
prema13 2015 年 10 月 19 日
how we find trainSet or testSet in form of row or column????
Stephen23
Stephen23 2015 年 10 月 19 日
編集済み: Stephen23 2015 年 10 月 19 日
It is not clear what you mean by "how we find trainSet or testSet in form of row or column": do you want to select columns of data from the matrix, or split the matrix column-wise into test and training sets?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by