Alternative of REPMAT routine when working with BSXFUN for a large vector
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dear coder, To make thing clear, I will explain the situation with reference to details along with the code below
%%In simple form, the case can be understand as the following
DataSet=5; % 5 data points for each subject
TotalSub=1;
T_sub1=rand((DataSet*TotalSub),1); % For first subject
T_sub2=rand((DataSet*TotalSub),1); % For Second subject
Constant_s=rand(5,2); % Column 1 & 2 represent T1 and T2 respectively
%%Multiplication between each subject to the constant
T_sub1_Constant_s=bsxfun(@times,T_sub1,Constant_s);
T_sub2_Constant_s=bsxfun(@times,T_sub2,Constant_s);
%%In a compact form, we solve similar problem such as
NSub=2; % Assume we have two subjects
T_sub1N2=rand((DataSet*NSub),1); % For first and second subject
Constant_s_rp=repmat(Constant_s,NSub,1); % HOW TO avoid using REPMAT?
T_sub1N2_Constant_s=bsxfun(@times,T_sub1N2,Constant_s_rp);
Yet, as the size of the Constant_s and total subject increase, the vector become extremely large, and using repmat to create these matrices become slower and worse consume to much memory.
I wonder if there is other ways to make the computation fast and memory efficient. I also try KRON, but it does not give me the desired output.
Thanks in advance.
2 commentaires
Jan
le 6 Déc 2017
The question would be easier to understand, if you simply provide some test data created by rand(). What are the sizes of a and b? Without your help_repmat.mat file, this is impossible to find out. Which vector becomes "extremely large" and how large is this in absolute numbers?
Réponses (0)
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!