Mercurial > hg > camir-aes2014
annotate toolboxes/MIRtoolbox1.3.2/MIRToolbox/peaksegments.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
rev | line source |
---|---|
wolffd@0 | 1 function y = peaksegments(func,d,p,varargin) |
wolffd@0 | 2 |
wolffd@0 | 3 y = cell(1,length(d)); |
wolffd@0 | 4 for h = 1:length(d) |
wolffd@0 | 5 if not(iscell(d{h})) % for histograms |
wolffd@0 | 6 p{h} = {p{h}(:,:,1)'}; |
wolffd@0 | 7 d{h} = {d{h}'}; |
wolffd@0 | 8 end |
wolffd@0 | 9 for i = 1:length(d{h}) |
wolffd@0 | 10 %sum(var(p{h}{i},1,2)) |
wolffd@0 | 11 %p{h}{i} = repmat(p{h}{i}(:,1,1),[1,size(p{h}{i},2),size(p{h}{i},3)]); |
wolffd@0 | 12 d{h}{i} = d{h}{i} + repmat(min(d{h}{i}),[size(d{h}{i},1),1,1]); |
wolffd@0 | 13 for j = 1:size(d{h}{i},3) |
wolffd@0 | 14 for k = 1:size(d{h}{i},2) |
wolffd@0 | 15 yk = []; |
wolffd@0 | 16 nb = 0; |
wolffd@0 | 17 f = find(not(isnan(d{h}{i}(1:end,k,j)))); |
wolffd@0 | 18 while not(isempty(f)) |
wolffd@0 | 19 l = f(1); |
wolffd@0 | 20 f = find(isnan(d{h}{i}(l:end,k,j)))+l-1; |
wolffd@0 | 21 if isempty(f) |
wolffd@0 | 22 f = size(d{h}{i},1)+1; |
wolffd@0 | 23 end |
wolffd@0 | 24 r = l:f(1)-1; |
wolffd@0 | 25 if length(r)>1 |
wolffd@0 | 26 nb = nb+1; |
wolffd@0 | 27 if nargin > 3 |
wolffd@0 | 28 for g = 1:length(varargin) |
wolffd@0 | 29 if g == 1 |
wolffd@0 | 30 v{g} = repmat(varargin{g}{h}{i}{1,k,j}(nb),... |
wolffd@0 | 31 [length(r),1,1]); |
wolffd@0 | 32 else |
wolffd@0 | 33 v{g} = varargin{g}{h}{i}{1,k,j}(nb); |
wolffd@0 | 34 end |
wolffd@0 | 35 end |
wolffd@0 | 36 else |
wolffd@0 | 37 v = {}; |
wolffd@0 | 38 end |
wolffd@0 | 39 yk(nb,1) = func(abs(d{h}{i}(r,k,j)),... |
wolffd@0 | 40 p{h}{i}(r,k,1),... |
wolffd@0 | 41 v{:}); |
wolffd@0 | 42 end |
wolffd@0 | 43 f = find(not(isnan(d{h}{i}(f(1):end,k,j))))+f(1)-1; |
wolffd@0 | 44 end |
wolffd@0 | 45 y{h}{i}{1,k,j} = yk; |
wolffd@0 | 46 end |
wolffd@0 | 47 end |
wolffd@0 | 48 end |
wolffd@0 | 49 end |