how to repalce the bigger index of upper triangular matrix by lower index.and according to that want to change matrix label number. MATLAB -


i m having vector of detected speaker change point`

scp=[10 25 43]; 

from made mtrix

seg_result=           start-time   end-time speaker1  1            10 speaker2  10           25 speaker3  25           43 speaker4  43           end-time of audio wav(for ex: 50) 

after did homogeneous speaker clustering.result of matrix in lower triangular matrix zero,matrix follows,

cluster_result=  0   -567   345   324 0     0    567   768 0     0     0    534 0     0     0     0 

then detected negatives number in matrix.

for i=2:length(cluster_result)     j=(i+1):length(cluster_result)         if cluster_result(i,j)<0 

here value @ cluster_result(i,j),means distance value between speaker(i) , speaker(j),for ex:cluster_result(1,2) means distance value between speaker1 , speaker2. .now ones negative numbers cluster_result,i need following

1) index of negative numbers. 2) want replace j i,means want speaker2 should become speaker1.and want create(or u can replace previous seg_result matrix) follow

seg_result=           start-time   end-time speaker1  1            10 speaker1  10           25 speaker3  25           43 speaker4  43           end-time of audio wavfile(for ex: 50) 

your appreciated heartily...

you can use find() in following way:

negatives= cluster_result<0; % logical operation, returns binary matrix 1 expression true/ equivalent loop. 

output:

negatives=      0     1     0     0      0     0     0     0      0     0     0     0      0     0     0     0 

then use find() 2 outputs indexes of non-zero elements of binary matrix:

[ii,jj]=find(negatives); if use 1 output, you'll linear index 

output:

ii =       1  jj =       2 

now have indexes ii , jj can replace , rearange them pleases you.

hope helps.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -