Alternative of REPMAT routine when working with BSXFUN for a large vector
조회 수: 2 (최근 30일)
이전 댓글 표시
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
Jan
2017년 12월 6일
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?
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!