Hi guys, I have an array for instance y=[1 2 3 4 5 6]
I want to output the values that its indexes are the middle of the left side and right of every pair with increasing index (I mean at index=1 and index=3 then the middle between is at index=2 , then I look at index=3 etc ..), this mean I look at 1 3 and the value 2 is the middle between those two pair, then I look on the other pair 3 5 and I print the value 4 ..etc
so my output in my case is an array that have the values that are the middle of every pair , in my case output=[2 4 5]
so how could I implement that in matlab? thanks alot for your help!

7 件のコメント

jonas
jonas 2020 年 7 月 19 日
why is 3 being excluded from the output array?
KSSV
KSSV 2020 年 7 月 19 日
[2 4 5] or [2 4 6]?
Mohamed Jamal
Mohamed Jamal 2020 年 7 月 19 日
[2 4 5]
Mohamed Jamal
Mohamed Jamal 2020 年 7 月 19 日
6 excluded because it's not between two values .. 5 is included because it's between 4 ,6 values
Mohamed Jamal
Mohamed Jamal 2020 年 7 月 19 日
sorry 3 also must be included !! sorry for the missing.
KSSV
KSSV 2020 年 7 月 19 日
Write your expected output.....[2 4 5]?
jonas
jonas 2020 年 7 月 19 日
perhaps you want to exclude the two edge values?

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

回答 (1 件)

カテゴリ

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

質問済み:

2020 年 7 月 19 日

回答済み:

2020 年 7 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by