Alternative of REPMAT routine when working with BSXFUN for a large vector

조회 수: 2 (최근 30일)
balandong
balandong 2017년 12월 6일
편집: balandong 2017년 12월 6일
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
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?
balandong
balandong 2017년 12월 6일
편집: balandong 2017년 12월 6일
Dear Jan, Thanks for comment, I already amend the question to a simpler form.
Which vector becomes "extremely large" and how large is this in absolute numbers?
With respect to the above question, the Constant_s.
The size of
DataSet=48;
TotalSub=1000;
Constant_s=rand(10000,10000);
As you can see, it is very large

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by