A number contain in a series.
1 view (last 30 days)
I have a series 's'
I find its subsequences like
and I have a set of points 'k'.
I need to check any of the subsequence contain any points of the K.If it contain I need to add those subsequence into a variable 'A'.How can I do this.Please help me.
thoughtGarden on 19 Sep 2019
Edited: thoughtGarden on 20 Sep 2019
You haven't provided enough information to be certain of what you want, but makeing some assumptions, this should work.
% "series" s, which is an array
s = 1:1:250;
% Build "subsequences"
for ii = 1:7
subSequence(ii,:) = s((ii-1)*30 + 1:ii*30);
% Build "set of points 'k'"
k = randi(1000,1,10);
% A will contain all subsequences that contain any of the values of k
A = ;
% In each loop, determine if there is any overlap betweent he subsequence
% and the variable k. If there is, add the subsequency to the variable A.
% Otherwise, move on to the next subsequence.
for ii = 1:length(subSequence(:,1))
A(end+1,:) = subSequence(ii,:);
% Disp A, which in the case of this script might be empty as k is random
This builds an array containing all the subsequences that contain any values found in k. If that is what you are looking for, this works.