find how many times sequences are present in a string array
Show older comments
Hi! I have
S={1;[1 631];[1 631 618];[1 631 618 574];[1 631 618 574 608];631;[631 618];[631 618 574]}
and
T={'1' '596' '674' '' '' '' '' '';'674' '631' '1' '631' '1' '618' '631' '618';'641' '617' '674' '631' '654' '629' '625' '673';'674' '673' '674' '673' '674' '618' '631' '1';'674' '618' '1' '618' '631' '627' '631' '';'631' '1' '631' '674' '740' '' '' '';'739' '740' '733' '674' '631' '618' '631' '618';'674' '673' '674' '1' '641' '' '' '';'618' '1' '631' '618' '631' '618' '631' '618';'674' '631' '618' '631' '618' '631' '681' '675';'674' '631' '1' '631' '625' '618' '631' '';'641' '642' '618' '631' '618' '631' '627' '631';'618' '631' '1' '631' '1' '618' '631' '674';'674' '673' '674' '631' '674' '' '' '';'674' '719' '618' '631' '618' '631' '618' '631';'674' '631' '618' '631' '1' '618' '631' '627';'674' '673' '674' '673' '674' '631' '618' '1';'674' '631' '618' '631' '674' '' '' '';'674' '631' '618' '631' '618' '631' '618' '631';'674' '618' '631' '616' '545' '1442' '1595' '';'1' '1595' '1' '1583' '550' '674' '' '';'674' '631' '1' '631' '618' '' '' '';'674' '631' '618' '631' '' '' '' '';'1' '631' '618' '574' '608' '1' '608' '618';'626' '631' '1' '631' '618' '' '' '';'674' '673' '631' '618' '631' '659' '633' '631'}
and I want to know how many times the sequences in S are present in T.
E.g.
- First sequence is 1 --> I search it in the first column of T (present three times)
- Second sequence [1 631] ---> I search 1 in first column of T e 631 in the second columns: they have to be present contemporary (they are present contemporary for 1 time)
- Third sequence [1 631 618] --> search 1 in first column of T, 631 in the second columns and 618 in the third columns: they have to be present contemporary (they are present contemporary for 1 time) and so on for all the others values
I want like output the sequences and the number of times that they are present in T, can you help me?
5 Comments
Azzi Abdelmalek
on 13 Apr 2016
Edited: Azzi Abdelmalek
on 13 Apr 2016
What is the result for this example? Make your question clear by giving a minimum of explanation
pamela sulis
on 13 Apr 2016
It is not clear what you mean when you state that "The sequence 1 is present in T 3 times" and that "631 is present 1 time", because the string '1' actually occurs nineteen times in T, and the string '631' occurs fifty-three times. Please explain exactly how you identified these sequences.
pamela sulis
on 13 Apr 2016
Edited: pamela sulis
on 13 Apr 2016
Guillaume
on 13 Apr 2016
Is that correct that T is made up of strings whereas S is made up of numbers? In that case, can we assume that the numbers are always integer?
Accepted Answer
More Answers (0)
Categories
Find more on Numeric Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!