Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.1k views
in Technique[技术] by (71.8m points)

matlab - Similarity matrix for harmonic percussive seperation

I want to make a similarity matrix for seperation of harmonic and percussive elements in a time series signal. The matrix is used to identify repeating elements. I use an STFT on my signal and then find the magnitude spectrum (V) by taking abs value. The similarity matrix is made by the matrix multiplication of V and transpose V. When I do this the dimentions do not match. The end product is supposed to be a chess-borad like similarity matrix with color shaded squares as a measure of similarity between corresponding elements in my STFT. How do I make the similarity matrix with the dimensions matching the STFT? Thank you.

The signal is an audio file as a vector so you can run it yourself.

clear all; close all;

sig=[0.000172632912430720;0.617881789803505;0.0860126018524170;-0.105702796019614;0.0972765861079097;0.225698672235012;-0.136091217398644;0.0439671655185521;0.234609842300415;-0.182392808608711;-0.0109390905126929;0.196271929889917;-0.213016842491925;-0.000707965344190598;0.184395656920970;-0.257187498733401;-0.0540986955165863;0.163929571397603;-0.232828861102462;-0.0867920722812414;0.142415414098650;-0.402033044665586;-0.107446117923246;0.103385185298976;0.307485913042910;-0.119384602876380;0.0788380440499168;0.287243154802127;-0.168218351704127;0.0519803879615210;0.259576053127603;-0.202838315672125;0.0135790962376632;0.226095884281676;-0.196921937895240;-0.0154515893518692;0.195169935788726;-0.286725205281982;-0.0346261057002266;0.169265660864767;-0.233087153654196;-0.0748047502638656;0.138531572069041;-0.431823407241609;-0.112376269113156;0.283053733408451;0.427872389554977;0.0722545906901360;0.0812238138169050;0.357233799993992;-0.147939129732549;0.104219384491444;0.264004406519234;-0.210657524727139;-0.0104879532009363;0.274469055235386;-0.171520242467523;-0.0819984041154385;0.174371162429452;-0.275187874212861;-0.0458211144432426;0.166619600828199;-0.235156441107392;-0.0727996046189219;0.133460260462016;-0.451705735700671;-0.115607771091163;0.102171378064668;0.311365569999907;-0.126704567810521;0.0726536657972277;0.284498845343478;-0.157619561941829;0.0507471187156625;0.256081394472858;-0.214468625898007;0.0149150117067620;0.226538838003762;-0.204746735777007;-0.0216705046186689;0.192713218217250;-0.266551783250179;-0.0409628507768502;0.163964933773968;-0.271119693992659;-0.0692881366849178;0.137815916474210;-0.459041132795392;-0.116138024155589;-0.00202866643667221;0.743455499410629;-0.0381905362010002;0.0253902226686478;0.167868278920650;-0.112293735146523;0.106954902410507;0.280552111566067;-0.241262365132570;0.0200783386826515;0.207922812551260;-0.207970269955695;-0.0750641934573650;0.185407415498048;-0.269708804786205;-0.0435074057895690;0.168524604756385;-0.306809216737747;-0.0715196738019586;0.138542026048526;-0.452285379666137;-0.114697047989466;0.103998934791889;0.310505320434459;-0.141518962176633;0.0678907583351247;0.280934844711737;-0.150657214922830;0.0438195396272931;0.252274212427437;-0.212287013710011;0.0171017827087780;0.223899192991667;-0.227671486791223;-0.0234777604928240;0.191345335944789;-0.238613911918947;-0.0510586857562885;0.158889811325935;-0.320318245561793;-0.0682388162676944;0.134368810453452;-0.431048123224173;-0.112184981291648;0.231992714107037;0.214743971824646;0.0287589579820633;0.0353729799389839;0.0745287090539932;0.00783614814281464;0.0976103432476521;0.287389207631350;-0.257240083068609;0.0270334873348475;0.240629229694605;-0.239291273173876;-0.0198695870349184;0.220658177509904;-0.212501536123455;-0.0539374874206260;0.158310569415335;-0.341493974032346;-0.0694245725171641;0.138740736991167;-0.396154486690648;-0.108408711268567;0.103598154571955;0.310759548796341;-0.152737682044972;0.0679067238233984;0.278684707009234;-0.157150394865312;0.0365426212374587;0.247800817465759;-0.198118085289025;0.0154654063595474;0.220516459783539;-0.251520165642432;-0.0196707831346430;0.191145737266197;-0.221689411846455;-0.0587254653801210;0.156489157539909;-0.354910862297402;-0.0757652992033400;0.128416782143177;-0.349620315420907;-0.104971148713958;0.283346347510815;0.228282757103443;0.0916838496923447;0.131531290709972;0.219524674117565;-0.206832706928253;0.0924596637487412;0.302114866673946;-0.285081788897514;0.0548587990924716;0.135256849229336;-0.328231804072857;-0.0311689749360085;0.174057699739933;-0.230347363278270;-0.0511384429410100;0.155614587565651;-0.360499068367062;-0.0894592544063926;0.126596485497430;-0.292650966031943;-0.102839553204831;0.100902712321840;0.307589569623815;-0.154187525098678;0.0687738747510593;0.278339391457848;-0.173821503703948;0.0320246734190732;0.245022656337824;-0.185176437371410;0.00900809379527345;0.216600085463142;-0.261477998687042;-0.0166005493229022;0.189506555616390;-0.229202798363986;-0.0600065020262264;0.156214242699207;-0.355142824875657;-0.0867679978837259;0.123693930392619;-0.229148323123809;-0.102414153225254];


window=hann(100,'periodic');
overlap=floor(numel(window)/2);
nfft=2^nextpow2(numel(window)+1);
X=stft(sig,'Window',window,'OverlapLength',overlap,'FFTLength',nfft); 

V=abs(X); 

Vnorm=vecnorm(V);           % Norm of each column
Vnormalize=V./Vnorm;

S=Vnormalize*Vnormalize'; 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...