Lookup values in a 6-D matrix using indices from columns of another matrix.
Show older comments
Trying to look for values in the v_tbl based on index provided by each column of quant_sysplus.
Problem: Runs too slow because I'm using two For loops. Is there a faster way of accessing the values?
v_tbl is a 6-D array that contains values of interest. quant_sysplus is 3-D (1:6,1000,3) array with each column containing a set of indices (1:6) to a value in v_tbl.
The following is what I have so far and it works, but there are a lot of states (121x121x24x7x7x3) that I have to step through. The two For Loops makes it extremely slow when I have 3000 sets of indices to lookup in each state.
for ind_page=1:page %page=3
for ind_col=1:Np %Np=1000 lookup(1,ind_col,ind_page)=v_tbl(quant_sysplus(1,ind_col,ind_page),quant_sysplus(2,ind_col,ind_page),quant_sysplus(3,ind_col,ind_page),quant_sysplus(4,ind_col,ind_page),quant_sysplus(5,ind_col,ind_page),quant_sysplus(6,ind_col,ind_page)); % Returns the values for each sample
end
end
I've tried Parfor as well, but was slower probably because the comm overhead was high.
Any suggestions?? Thank you.
David
4 Comments
Sara
on 31 Jul 2014
Have you tried (no loops)
lookup(1,:,:)=v_tbl(quant_sysplus(1,:,:),quant_sysplus(2,:,:),quant_sysplus(3,:,:),quant_sysplus(4,:,:),quant_sysplus(5,:,:),quant_sysplus(6,:,:));
David Hung
on 31 Jul 2014
Sara
on 31 Jul 2014
Can you attach your arrays? Just to see what's going on and test different solutions for speed.
David Hung
on 31 Jul 2014
Accepted Answer
More Answers (0)
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!