# Matlab default vector orientation

12 visualizzazioni (ultimi 30 giorni)
Tim il 3 Feb 2021
Commentato: Tim il 11 Feb 2021
Initializing a vector using indices always results in a row vector, even if the indices and the RHS are column vectors, e.g:
a([1; 2; 3]) = ones(3, 1);
results in row vector [1, 1, 1]. Similarly, if I define a vector incrementally, e.g.:
a(1) = 1;
a(2) = 1;
This results in a row vector, [1, 1].
Has defining a vector this way in Matlab always defaulted to row vector format (vs. column vector) in previous versions? I seem to recall, when begining Matlab several years ago, that vectors defaulted to column format not row format. I'm debugging someones code and it is crashing precisely because their code makes the same assumption about the orientation of vectors generated using indices and I'm wondering if Matlab switched some time but I don't have any old versions available to check this. Thank you,
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposte (1)

darova il 11 Feb 2021
a(1:3,1) = 1:3;
b(1,1:3) = 1:3;
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Tim il 11 Feb 2021
Thank you for the reply but this is not what I'm asking. My question is if, in previous versions of Matlab, A(1) = 1, A(2) = 2 resulted in a column or row vector if A was previously undefined and the vector indices were defined sequentially. I seem to recall it resulting in a column vector in the past but now it seems to result in a row vector.

Accedi per commentare.

### Categorie

Scopri di più su Matrix Indexing in Help Center e File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by