Borrar filtros
Borrar filtros

Patterns in matlab

1 visualización (últimos 30 días)
Mate 2u
Mate 2u el 7 de Mayo de 2012
Hi all,
Thank you so much for your help on the forum. I need help. I have some data and I want to check each substring within the data (Value n) and then check if pattern occurs more than once, and if the pattern occurs more than once to calculate the correlation (Value X) of the number of elements after the substring has occured.
For example for an array A:
A = [1 2 2 2 1 2 3 4 1 2 2 2 2 1 2 3 4]
As n = 2. We check every sub-string of size 2. So it checks [1 2], [2 2], [2 2], [2 1].......up to [3 4].
now lets check the first substring which is [1 2]....as X is 2 it will give correlation of 2 values which occur after the pattern at all positions.
eg FIRST output in ARRAY Z would be correlation of [2 2] vs [3 4] vs [2 2] vs [3 4]
Then it will consider the second substring [2 2]
I have a work in progress code as follows
A = [1 2 2 2 1 2 3 4 1 2 2 2 2 1 2 3 4]
n=2; %n
X=2;
for i =1:length(A)-n+1
ZZ= strfind(A,A(i:i+n-1));
if length(ZZ)=1
C(i)=0;
else
for j=1:length(ZZ)
C(i)=corrcoef(
%%This is where I need help.
end
Thank you so much.
  2 comentarios
Image Analyst
Image Analyst el 8 de Mayo de 2012
What the heck is X? It's not used in your code and I didn't understand your explanation of it. Also I don't know what this means: "correlation of [2 2] vs [3 4] vs [2 2] vs [3 4]". As far as I know you correlate one signal against another signal, and thatdoesn't seem what you're doing. Plus correlation (like from xcorr(), xcorr2(), or normxcorr2()) is different than the correlation coefficient (the corrcoeff() function you used.) Bottom line: I don't know what you want.
Sargondjani
Sargondjani el 8 de Mayo de 2012
i thought it was just me who didnt understand...

Iniciar sesión para comentar.

Respuestas (1)

KUSHAL
KUSHAL el 1 de Nov. de 2012
Even I didn't understand what you need exactly. Kindly put your question neatly and what are your requirements and inputs given for that.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by