Need to combine doubles with different sizes
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
jgillis16
il 19 Gen 2016
Commentato: jgillis16
il 20 Gen 2016
I need to combine a set of doubles into one double matrix. My problem is that they are all different sizes. How would I go about doing this?
3 Commenti
Walter Roberson
il 19 Gen 2016
Are you trying to put each member into a row (or column) with them starting as different lengths, and you want to end up with a rectangular matrix that has NaN in each location where there was no value?
Risposta accettata
Walter Roberson
il 19 Gen 2016
If packing by columns then
YourXArray(1:length(x), Column_Number) = x;
If the x is larger then the current maximum number of rows then the array will be automatically grown and padded with 0s. If you want a different pad value then you need to indicate to us what padding you want.
3 Commenti
Walter Roberson
il 20 Gen 2016
Then perhaps you should be padding with something else like -inf or nan
Lx = length(this_x);
if Lx > size(YourXArray,1)
YourXArray( size(YourXArray,1)+1 : Lx, :) = PadValue;
end
YourXArray(1:Lx, ColumnNumber) = x;
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrix Indexing 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!