Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
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 Kommentare
Jan
Jan am 6 Dez. 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?
balandong
balandong am 6 Dez. 2017
Bearbeitet: balandong am 6 Dez. 2017
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

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by