how to display an array with its position

i have an array such as X=[1 2 3 4 5 6 7 8 8 7 8 6 4 5 3 1]
i want to display the output as X(1)=1 X(2)=2

1 件のコメント

madhan ravi
madhan ravi 2019 年 8 月 11 日
編集済み: madhan ravi 2019 年 8 月 11 日

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

回答 (1 件)

SYED IMTIAZ ALI SHAH
SYED IMTIAZ ALI SHAH 2019 年 8 月 11 日

0 投票

x(1) % it gives you the entry at location 1
x(2) % it gives you the entry at location 2
c = find(x == 2) % gives you the position of 2 in array.

カテゴリ

ヘルプ センター および File ExchangeMultidimensional Arrays についてさらに検索

質問済み:

2019 年 8 月 11 日

編集済み:

2019 年 8 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by