フィルターのクリア

Create a new vector by adding and subtracting each element of original vector.

3 ビュー (過去 30 日間)
Alex
Alex 2019 年 8 月 6 日
編集済み: Adam Danz 2019 年 8 月 6 日
Hello community,
I want to create a new vector by adding and subtracting each element of orginal vector. How can I do?
Example: A = [3 8 99 61]
What I want is: Output B = [2 3 4 7 8 9 98 99 100 60 61 62]

採用された回答

madhan ravi
madhan ravi 2019 年 8 月 6 日
B = reshape(A + [-1;0;+1],1,[]) % or
B = reshape(bsxfun(@plus,A,[-1;0;+1]),1,[]) % if < = 2016a
  3 件のコメント
madhan ravi
madhan ravi 2019 年 8 月 6 日
Thanks Adam :), at first sight the question seemed to be unclear actually.
Alex
Alex 2019 年 8 月 6 日
Thanks Madhan.

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

その他の回答 (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