Michał Mielec
Michał Mielec

Reputation: 1651

SciLab is giving "submatrix is incorrectly defined" error

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

Answers (3)

wozai
wozai

Reputation: 11

If you care for speed, avoid calling repmat and use the Kronecker product .*.

C_tmp = ones(T_SIZE, 1) .*. C;

Upvotes: 1

Roerto Vieytes
Roerto Vieytes

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

Michał Mielec
Michał Mielec

Reputation: 1651

Ok I found solution - repmat function do this job.

C_tmp = repmat(C, T_SIZE, 1);

Upvotes: 0

Related Questions