How to allow a single overlap during chain growth?

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 Comments

You may know what 'chain segment', 'chain growth', 'overlap' means for your code. The majority of us don't.
You've posted some code that has no useful comment (comments that explain what the code is doing, what the inputs and outputs are and what each variable is) so it's really unclear what is yiu're asking.
This function:
position=setdiff(Trajectory,check,'rows');
should allow me to get the rows that are in Trajectory and not in check,, right?
I need to get the rwos that are in Trajectory and was seen only once in check. I mean that they shouldn't be repeated in check more than once. Can you help with that?
Can there be any duplicate row in Trajectory?
No, Trajectory should be always unique. The duplication should be in check only.

Sign in to comment.

 Accepted Answer

%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

More Answers (0)

Categories

Find more on Biological and Health Sciences in Help Center and File Exchange

Products

Tags

No tags entered yet.

Asked:

on 3 Nov 2019

Edited:

on 3 Nov 2019

Community Treasure Hunt

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

Start Hunting!