Why is operator = is clever sometimes but not always?
Ältere Kommentare anzeigen
M = zeros(N,6);
M(:,1) = ones(N,1); % OK
M(:,2) = ones(1,N); % OK
M(:,[3,4]) = zeros(N,2); % OK
M(:,[5,6]) = zeros(2,N); % ERROR
Antworten (2)
Image Analyst
am 16 Jun. 2015
1 Stimme
And why shouldn't it give an error? You're trying to stuff a 2 row by N column matrix into an N row by 2 column space. The sizes of the rows and columns don't match up. You can't stuff a n-by-m matrix into an j-by-k space unless n equals j and m equals k (unless the matrix is a 1D vector).
Walter Roberson
am 16 Jun. 2015
1 Stimme
Vectors are treated differently as a convenience because most of the time row vector vs column vector is irrelevant to people.
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!