%This function runs through an array describing state space and %finds the paths and duration of it. It will return an array of %actual path durations from one metastable state to other. function [X,pathsAB,pathsBA]=TransitionPaths(S) size_s = size(S); X=[]; pathsAB = [[]]; pathsBA = [[]]; pTP=0; i=1; j=1; k1=1; k2=1; while(S(i) == 0) i = i+1; end curr_state = S(i) s_index = i i=i+1; while(i<=size_s(1)) if(S(i)==0) i = i+1; elseif S(i) == curr_state curr_state = S(i); s_index = i; i = i+1; elseif S(i) ~= curr_state %a path has been found X(j) = i-s_index; if S(s_index) == 1 pathsAB(k1,1) = s_index; pathsAB(k1,2) = i; k1 = k1+1; %%%%X(j) = i-s_index; %%%%j = j+1; elseif S(s_index) == 2 pathsBA(k2,2) = s_index; pathsBA(k2,1) = i; k2 = k2+1; end % if X(j) == 1 % i % S(i) % S(i-1) % end j = j+1; curr_state = S(i); s_index = i; i = i+1; end end