Info

This question is closed. Reopen it to edit or answer.

Help and account substrings extraction

2 views (last 30 days)
FRANCISCO
FRANCISCO on 10 Dec 2013
Closed: MATLAB Answer Bot on 20 Aug 2021
good, I wish to raise my problem, because I know how to do. I, for example have a long string as follows:
[3 -1 -1 -1 -1 -1 1 -1 -1 -1 0 -1 -1 -1 -1 4 -1 0 -1 -1 -1 0 -1 -1 3 -1 -1 -1 -1 -1 -1 4 -1 -1 0
-1 1 -1 -1 -1 0 -1 1 -1 -1 -1 -1 -1 -1 1 -1 0 -1 -1 4……..
What I want to do is the following:
1) extracting substrings so that starts for next 3/4 and ends 3/4 including the upcoming latter. For example:
[-1 -1 -1 -1 -1 1 -1 -1 -1 0 -1 -1 -1 -1 4]
Next substring;
[-1 0 -1 -1 -1 0 -1 -1 3]
Next substring;
[-1 -1 -1 -1 -1 -1 4]
And so on
2nd) I have to count occurrences of a given substring and also recounting the lengths associated with each substring:
For example we have:
a) [-1 -1 -1 1 -1 0 -1 4]
b) [-1 0 -1 -1 1 4]
SUBSECUENCE__________________REPETITIONS__________Nº(-1)
1 0 4 ----------------------------------------------------2---------------------------------5
1 0 4 ----------------------------------------------------2---------------------------------3
(Note: subsecuence is obtained by eliminating (-1))
We see that the pattern [1 0 4] repeats in a) and b) therefore is repeated twice. In a) there are 5 (-1). In b) there are 3 (-1). How could I make? I do not know how to do.
thank you very much

Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!