Reputation: 1651
I am trying to define vector C like this:
[0.67, 0.67, 0.67, 0.67, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02]
and then create matrix C_tmp like:
[0.67, 0.67, 0.67, 0.67, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02],
[0.67, 0.67, 0.67, 0.67, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02],
[0.67, 0.67, 0.67, 0.67, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02],
[0.67, 0.67, 0.67, 0.67, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02]
but I get "Submatrix incorrectly defined" error during last line execution.
C = zeros(1, X_SIZE);
C_tmp = zeros(T_SIZE, X_SIZE)
C(1:KSI) = 0.67;
C(KSI+1:$) = 0.02;
C_tmp(1:$) = C;
Upvotes: 0
Views: 1398
Reputation: 11
If you care for speed, avoid calling repmat
and use the Kronecker product .*.
C_tmp = ones(T_SIZE, 1) .*. C;
Upvotes: 1
Reputation: 11
You need an mxNc matrix R, where each row of it are de components of the vector C.
1) create a diagonal matrix with C
d = diag (c) (NcxNc matrix)
2) create the matrix of ones mxNc
o = ones (m, Nc) (mxNc matrix)
3) create the matrix R = o*d (mxNc matrix)
Upvotes: 1
Reputation: 1651
Ok I found solution - repmat function do this job.
C_tmp = repmat(C, T_SIZE, 1);
Upvotes: 0