How to allow a single overlap during chain growth?

3 ビュー (過去 30 日間)
Soma
Soma 2019 年 11 月 3 日
編集済み: Soma 2019 年 11 月 3 日
I have this code which doesn't allow any overlaps between chain segments. How can I modify it to allow a single overlap only.
Trajectory = [x+1 y;x-1 y;x y+1;x y-1];
check=reshape(old_steps(:,i),2,m/2)';
position=setdiff(Trajectory,check,'rows');
  4 件のコメント
Guillaume
Guillaume 2019 年 11 月 3 日
Can there be any duplicate row in Trajectory?
Soma
Soma 2019 年 11 月 3 日
No, Trajectory should be always unique. The duplication should be in check only.

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

採用された回答

Guillaume
Guillaume 2019 年 11 月 3 日
編集済み: Guillaume 2019 年 11 月 3 日
%this code only works if rows of Trajectory are unique
[intraj, where] = ismember(check, Trajectory, 'rows'); %find which row of check are in Trajectory and which row they match
trajcount = accumarray(where(intraj), 1, [size(Trajectory, 1), 1]); %and compute the histogram of the rows found in Trajectory
position = Trajectory(trajcount == 1, :); %to get the rows that are only once in check
%or
position = Trajectory(trajcount <= 1, :); %to get the rows that are not in check or just once
  1 件のコメント
Soma
Soma 2019 年 11 月 3 日
Amazing!! Thank you so much!!

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

その他の回答 (0 件)

カテゴリ

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

タグ

タグが未入力です。

製品

Community Treasure Hunt

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

Start Hunting!

Translated by