フィルターのクリア

Find max cell and its location

1 回表示 (過去 30 日間)
Nasser Hakami
Nasser Hakami 2020 年 2 月 27 日
コメント済み: Nasser Hakami 2020 年 2 月 28 日
I have two vector x and y. I did maultiplication for coreesponding cell as belwo
x=[1 3 5 7 2 0 4];
y=[2 4 6 1 6 8 1];
for i=1:7
z(i)=x(i)*y(i);
end
w=max(z)
%%%%%%%%%%%%
the answer is
z = [ 2 12 30 7 12 0 4]
w = 30
I need to know the location of value w in z vector and i expect the answer to be
index_w= 3

採用された回答

Andrés Castro
Andrés Castro 2020 年 2 月 27 日
編集済み: Andrés Castro 2020 年 2 月 27 日
Hi Nasser:
You can perform in an easy way.
V = 2*(1:10) % An arbitrary vector
[M,I] = max(V) % Where M = maximum and I = the index of V
The code produces the following
V =
2 4 6 8 10 12 14 16 18 20
M =
20
I =
10
If you want to learn more about visit max functionc .
  1 件のコメント
Nasser Hakami
Nasser Hakami 2020 年 2 月 28 日
thanks alot

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by