Background
I stumbled upon a behaviour in octave where one of my vectors is a column vector on odd runs of a programme and a row vector else. I need to understand this extremely dangerous behaviour. The following is my attempt to understand.
Programme
My programme bugtest.m looks as follows:
IPMatrixCH = csvread("BugChn.csv"); %has 2 rows
IPCH = IPMatrixCH(:,5);
%Defining a longer shifted vector starting with NaN
IPCH_sh(1) = NaN;
IPCH_sh(2:3) = IPCH(1:2);
IPCH_sh = transpose(IPCH_sh)
Now, if I run this as first and second command after starting octave, I get:
octave:1> bugtest
IPCH_sh =
NaN
-1.1946
-1.1445
octave:2> bugtest
IPCH_sh =
NaN -1.1946 -1.1445
Questions
Is my understanding correct that
vecname(i) = value
by default sets the ith component of a ROW vector? My initial idea was that IPMatrixCH would be defined afresh with every call of the programme. Then IPCH would always be a column vector but
IPCH_sh(1) = NaN;
IPCH_sh(2:3) = IPCH(1:2);
would always fill a row vector. Or is IPCH(1:2); ruining this?
Is the observed behaviour because the file is not read afresh, or because octave remembers the orientation of IPCH_sh from the previous run? Or something entirely different? Is there a way to set the orientation of the vector absolutely and not relatively to before? I think that
clear
at the end of the programme resolves the problem, but I would like to understand why it happens!
Input File
Probably unimportant, but for completeness:
"6937",710,26,3,-1.194589,-3.644845,-2.504086,-2.176433,-1.138847,-0.3499769,-0.1842375,0.4976374,"CHN","China"
"6938",710,27,12,-1.144478,-3.201522,-2.375686,-2.029686,-1.09237,-0.327337,-0.13236,0.4428251,"CHN","China"
question from:
https://stackoverflow.com/questions/65924859/how-not-to-transpose-vector-between-runs