vector indexing in different dimension

1 回表示 (過去 30 日間)
Aditya
Aditya 2019 年 4 月 29 日
コメント済み: Aditya 2019 年 5 月 2 日
Hello everyone,
i am looking for a way to do the following without a for loop.
Suppose i have an array C of 100 elements and i have some events in the array (3 events) that i want to perform operation on.
A = [1; 20; 35;] this is the start index of those events
B = [5; 22; 55;] this is the end index of those events
how can i in one command for example do the following?
max(C(A:B)) where it should look for the max element of the event using index of A(1):B(1), A(2):B(2) and A(3):B(3)
thank u

採用された回答

Stephane Dauvillier
Stephane Dauvillier 2019 年 4 月 29 日
You can use arrayfun function:
arrayfun(@(a,b) max(C(a:b)),A,B)
  1 件のコメント
Aditya
Aditya 2019 年 5 月 2 日
many thanks :-)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOperators and Elementary Operations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by