Tuesday, 15 February 2011

signal processing - sparse indexing in matlab -



signal processing - sparse indexing in matlab -

i have long code total of next "if"s , matlab editor gives me suggestion follow:

this sparse indexing look slow

mt = rand(200,200); [c r] = size(mt); t = sparse(r*c,2); = 1:c j = 1:r if(ind(j,i)==1) templat = template + 1; t((i-1)*r+j,2)=100000; end end; end;

is there way can create code faster , matlab's suggestion? (the code may not run, because picked few lines , tried show issue)

the nested for's , if equivalent next vectorized code:

[jj, ii] = find(ind==1); %// jj rows, ii columns templat = template + numel(ii); t((ii-1)*r+jj,2) = 10000;

matlab signal-processing sparse-matrix

No comments:

Post a Comment