Please explain the above commands,

a=[7 3 5; 6 2 1]; dd=find(a<4)
dd =
3
4
6
How it is possible to display the 4 in that ans? and my condition is to find the <4 values in matrix a. But how it was display the 4 also?
Please anyone explain me...

 採用された回答

Mischa Kim
Mischa Kim 2014 年 5 月 14 日
編集済み: Mischa Kim 2014 年 5 月 14 日

0 投票

Ramya, dd contains the position numbers of all elements in matrix a that are smaller than 4, which would be 3, 2, and 1.
a =
7 3 5
6 2 1
The position number of the elements is counted sequentially row by row, and column by column:
1 3 5
2 4 6
If you want row and column indices use
[r,c] = find(a<4)

3 件のコメント

RAMYA
RAMYA 2014 年 5 月 15 日
Okay, yet I didn't get it exactly. bcoz, whenever I display the row and col indices, it displays the above,
a=[7 3 5; 6 2 1]; [r c]=find(a<4)
r =
1
2
2
c =
2
2
3
Sorry, I can't able to understand, could you explain it briefly? Bcoz, yet I getn't clear about the 4 in output dd.
Mischa Kim
Mischa Kim 2014 年 5 月 15 日
MATLAB numbers matrix elements top-down (rows) and left-right (columns). So for matrix
a =
7 3 5
6 2 1
7 would be the first, 6 the second, 3 the third and 2 the fourth (4) element. That's the 4 you get in
dd = find(a<4)
dd =
3
4
6
The first element in a that's smaller then 4 is 3, which is the third matrix element. The last one is 1, which is on position 6 in the matrix.
RAMYA
RAMYA 2014 年 5 月 16 日
ya sir........ thank u :) i got it... thanks for your valuable reply :)

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

その他の回答 (0 件)

カテゴリ

タグ

質問済み:

2014 年 5 月 14 日

コメント済み:

2014 年 5 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by