- B(1:end) uses linear indexing. The size of the output is the same as the size of the index (which in your example is a 1xN vector).
- B(:) is a special syntax that always returns a column vector.
If B is a matrix,what is the difference between B(1:end) and B(:)
17 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Alejandro Duque Salazar
le 6 Jan 2020
Modifié(e) : Stephen23
le 6 Jan 2020
If B=[1 2 ; 3 4]
B(1:end) returns [1 3 2 4] as a row vector and B(:) returns it as a column vector.
What is the difference?
0 commentaires
Réponse acceptée
Stephen23
le 6 Jan 2020
Modifié(e) : Stephen23
le 6 Jan 2020
Given a matrix B:
Loren Shure's blog explained the first syntax as "C = A(B) produces output the size of B unless both A and B are vectors... When both A and B are vectors, the number of elements in C is the number of elements in B and with orientation of A."
See also:
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!