0

problem matrix dimension

Hello,

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 :

xnew=zeros(dim,1);

Then I copy the values of x (big vector) to xnew (same but smaller) with a loop :

for i=1:dim

xnew(i,1)=x(i,1);

end

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

0

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.

Login to add comment