Why does linspace create row instead of column?
Show older comments
In Matlab, array indexing is column based. For instance
A = [1,2;3,4]; % My matrix A
b = A(:); % This is a column vector b = [1;2;3;4]
So I was wondering if there is a reason why the linspace function creates a row vector
c = 1:4; % The vector is c = [1,2,3,4], a row vector
Is there a rationale in Matlab for this? Why doesn't linspace create a column by default, if that's the natural way to index things in Matlab?
I know this has little practical import, but it's bugging me that it was designed that way.
Edit: I thought linspace() and the semicolon operator were identical in that context. That appears not to be true. Either, it does not change the question.
2 Comments
Walter Roberson
on 23 May 2019
c = 1:4
uses the colon operator, not the linspace function. linspace would look like,
c = linspace(1, 4, 4)
Benjamin D'Anjou
on 23 May 2019
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!