problem matrix dimension


I have a matrix problem with quite a simple code. The point of this code is to create a new vector, similar to a previous one, but with a different dimension.
The dimension of the new vectors created is set by a variable value, which I call "dim" in my code. I want to create a new vector "xnew" which has same values as the vector "x" which I created previously in my code.
So I create first a zero matrix :
Then I copy the values of x (big vector) to xnew (same but smaller) with a loop :
for i=1:dim
Problem : if I display my new vector (xnew), the last line is missing. If I check the size of the matrix "xnew", it gives me a line dimension which is one unit less than the variable "dim". But if I display this variable "dim" at any part of the code, I always have dim which has the good value, but the matrix systematically miss one unit and has a dimension of (dim-1, 1).
This is for me very strange, and if I use constant values I don't have this problem. Does somebody have a clue of the potential reason of this?

Scilab 13-11-17, 5:47 p.m. Timmy



It's for me like my variable "dim" is equal to something all the time, whenever I display it, but when it's used within the matrix, it equal to this value - 1.

13-11-17, 6:10 p.m. Timmy

Log-in to answer to this question.