Borrar filtros
Borrar filtros

How to find exact match for negative value.

2 visualizaciones (últimos 30 días)
Kugen Raj
Kugen Raj el 29 de Feb. de 2012
Y=sum(y);
YY=abs(Y);
p=20*log10(YY/max(YY));%normalized power in dB.
P=round(p);
[c]=find(P==-3);
bw=c(1,2)-c(1,1);
I used this find() function to find all the vectors that has the exact value. But, then i have this error:
??? Attempted to access c(1,2); index out of bounds because size(c)=[1,0].
Error in ==> Q10 at 54
bw=c(1,2)-c(1,1);

Respuestas (1)

the cyclist
the cyclist el 29 de Feb. de 2012
If no element of P is equal to -3, then c will be empty, and you will get this error.
  4 comentarios
Kugen Raj
Kugen Raj el 29 de Feb. de 2012
i see.thanks for your suggestion. i will try this one out and check for the results.
the cyclist
the cyclist el 29 de Feb. de 2012
Two comments. One is that since you are checking against -3, not +3, the check should have been abs(P+3)<tol. Second, I would still say your rounding approach should have worked here, so my suspicion is that for some reason, your vector P does not actually have values near -3. You could breakpoint the code before the error occurs, to look at the values.

Iniciar sesión para comentar.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by