Organize vector, extract indices

3 ビュー (過去 30 日間)
Fidele Adanvo
Fidele Adanvo 2020 年 11 月 27 日
コメント済み: Stephen23 2020 年 11 月 28 日
Hello, everything okay?
How can I efficiently do the following are between one by one in vector A?
A=[2 4]
B=[2 70 8 29 98 100]
I need to put in Out the indexes of vector B that are different from the indexes of A.
Out=find(B~=B([A]))
This is the output I need.
Out =[1 3 5 6].

採用された回答

Stephen23
Stephen23 2020 年 11 月 27 日
A = [2,4];
B = [2,70,8,29,98,100];
Out = setdiff(1:numel(B),A)
Out = 1×4
1 3 5 6
  3 件のコメント
Fidele Adanvo
Fidele Adanvo 2020 年 11 月 28 日
If I need to calculate the difference between the adjacent elements and know the size of the vector a priori, you will know what to tell me?
Por exemple..
A=[1,4,6,10,33,200];
out=[(A(1)-A(2), A(2)-A(3), A(3)-A(4),...........A(n-1)-A(n)]
Important vector do not follow any rule or sequence.
Stephen23
Stephen23 2020 年 11 月 28 日
A = [1,4,6,10,33,200];
out = -diff(A)
out = 1×5
-3 -2 -4 -23 -167

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

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