Effacer les filtres
Effacer les filtres

Equivalent of [C{:}] for vertcat

3 vues (au cours des 30 derniers jours)
Luca Amerio
Luca Amerio le 21 Déc 2016
Commenté : Matt J le 28 Déc 2016
To concatenate horizontally the content of a cell array we can use the very practice syntax [C{:}]. For example:
A = {(1:3) (4:7)};
B = [A{:}]
B =
1 2 3 4 5 6 7
Is there a way to obtain the same results in the vertical direction (except vertcat of course)
A = {(1:3)' (4:7)'};
B = ?
B =
1
2
3
4
5
6
7

Réponse acceptée

Matt J
Matt J le 21 Déc 2016
Modifié(e) : Matt J le 21 Déc 2016
Well, it's not vertcat...
B=cat(1,A{:})
But no, I don't think there's a way purely with operator syntax.
  1 commentaire
Walter Roberson
Walter Roberson le 21 Déc 2016
Correct, there is no operator syntax for this.

Connectez-vous pour commenter.

Plus de réponses (3)

José-Luis
José-Luis le 21 Déc 2016
Modifié(e) : José-Luis le 21 Déc 2016
EDIT
cell2mat(A')
  2 commentaires
Luca Amerio
Luca Amerio le 21 Déc 2016
Modifié(e) : Luca Amerio le 21 Déc 2016
This won't work if, as I did on purpose in the example, the vectors inside C are not all the same length.
Moreover, even if the are, the result is not the wanted one.
José-Luis
José-Luis le 21 Déc 2016

Connectez-vous pour commenter.


KSSV
KSSV le 21 Déc 2016
  1 commentaire
Luca Amerio
Luca Amerio le 21 Déc 2016
"except vertcat of course"
Thank you, but as [C{:}] is an equivalent for horzcat(C{:}), I was asking myself if there was such an equivalent for vertcat too..

Connectez-vous pour commenter.


Greg
Greg le 28 Déc 2016
Do exactly the same thing, then transpose B...
A = {(1:3) (4:7)}; B = [A{:}]'
  1 commentaire
Matt J
Matt J le 28 Déc 2016
This only works when the elements of A are row vectors, not column vectors, as in the OP's example.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by