フィルターのクリア

Say I have a matrix [2, 7, 8, 11, 10]. If I were to enter the number '11', how do I get matlab to display '4' (ie. the 4th element)

2 ビュー (過去 30 日間)
Jordan Macdonald
Jordan Macdonald 2017 年 3 月 23 日
編集済み: Mehdi Gh 2017 年 3 月 23 日
Say I have a matrix [2, 7, 8, 11, 10]. If I were to enter the number '11', how do I get matlab to display '4' (ie. the 4th element)?

回答 (1 件)

Mehdi Gh
Mehdi Gh 2017 年 3 月 23 日
編集済み: Mehdi Gh 2017 年 3 月 23 日
name your matrix first:
A = [2, 7, 8, 11, 10];
in your case it is a vector! to get your hand on the 4th element (here the 11) just type A(4).
if you meant to know which element is 11 in the vector A, then you should use find(). Below it finds the number of the element that is 11.
elmNo = find(A==11)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by