Merging empty vector with double
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi
I have two vectors:
9x1
A=[1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7 ; 8 ; 9]
B=[]
I want to compare A and B in the same matrix. Like
9x2
C=[A B];
But B is empty, How can I display this in the same matrix?.
The length of the vectors will vary, so the number of rows in C should be the same as the longest vector out of A and B.
2 commentaires
Stephen23
le 13 Avr 2023
Modifié(e) : Stephen23
le 13 Avr 2023
"How can I display this in the same matrix?."
Display what exactly?
Numeric matrices cannot have "holes" in them, so what value/s would you put in the "empty" locations? By default, numeric matrices are filled with zeros, which then could not be distinguished from zeros from your actual data.
Réponse acceptée
Stephen23
le 13 Avr 2023
"if B is empty, I want it to be shown as 9 zeros"
A = [1;2;3;4;5;6;7;8;9];
B = [];
C = [];
C(1:numel(A),1) = A;
C(1:numel(B),2) = B
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical 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!