Same number of columns, but getting "Dimensions of arrays being concatenated are not consistent" error
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/526289/image.png)
The two arrays I'm trying to concatenate are both of column size 1, so why am I unable to horzcat them?
0 Commenti
Risposte (1)
Waseem AL Aqqad
il 21 Feb 2021
Modificato: Waseem AL Aqqad
il 21 Feb 2021
Hi Liam,
Your two arrays should have the same number of rows when you use horzcat.
d=[1;2;3;4;5;6;7];
f=[3;4;5;6;7;8;9];
horzcat(d,f)
Here is another example where f and d have different no. of columns but same no. of rows
f=[4 5;4 5;6 7;7 8;3 2;3 4;6 7];
d=[1;2;3;4;5;6;7];
horzcat(d,f)
2 Commenti
Waseem AL Aqqad
il 21 Feb 2021
Modificato: Waseem AL Aqqad
il 21 Feb 2021
Is it fine if we use vertcat?
y=ones(256,1);
y1=zeros(22,1);
[y;y1]; % or vertcat(y,y1);
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!