How I can append matrices of different dimensions in another matrix?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
SANDEEP SINGH RANA
am 14 Mai 2021
Kommentiert: SANDEEP SINGH RANA
am 14 Mai 2021
I want to make a empty matrix in which i want to append matrix of dimensions 3*1,4*1, 3*1,2*1 etc.
It is better if I am able to append through for loop because I have 8-10 matrix of dimensions 3*1,4*1, 3*1,2*1).
Please suggest by showing or refering example.
Thanks
2 Kommentare
David Fletcher
am 14 Mai 2021
Fundamentally, I suspect what you want to do isn't possible (at least not with a matrix) - you will need to use a cell array see here:
Akzeptierte Antwort
Stephan
am 14 Mai 2021
A = randi(10, 3, 1)
B = rand(4, 1)
C = randi(10,5,1)
D = vertcat(A,B,C)
2 Kommentare
Stephan
am 14 Mai 2021
Bearbeitet: Stephan
am 14 Mai 2021
I dont recommend to do so, because you have to transpose them additionally, which doesnt make much sense. If you need a row vector you could also transpose the result of my code instead of transposing all the elements and then use horzcat:
A = randi(10, 3, 1);
B = rand(4, 1);
C = randi(10,5,1);
D = (vertcat(A,B,C)).'
Maybe you might want to use a cell array:
D = {A, B, C}
There are a many ways to do what you want.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!