How to concatenate arrays of different size in a loop?

2 views (last 30 days)
I have been trying to concatonate arrays from multiple files in a loop. It worked fine when I could initialize a zeros array with set dimensions and append each column with a files data , such as:
set_length = 1875;
num_f = 18;
init = zeros(1875,18);
for i = 1: num_f
init(:,i) = file_content
But now I applied a filter to the data and the file_content arrays are all different, such as 105 x 1 or 371 x 1, is there any way I can set up the loop to concatonate these into one array?

Accepted Answer

KALYAN ACHARJYA
KALYAN ACHARJYA on 1 Dec 2019
Edited: KALYAN ACHARJYA on 1 Dec 2019
How to concatenate arrays of different size in a loop?
result=0;
for i=1:iter_num
x_new= % array New generation
result=[result,x_new]
end
  5 Comments
Kyle Vanlerberghe
Kyle Vanlerberghe on 1 Dec 2019
My problem was that my array was 105 x 1 instead of 1 x 105, I just had to use the transpose of my x_new array. Thank you so much for your help
KALYAN ACHARJYA
KALYAN ACHARJYA on 2 Dec 2019
One way do the transpose and save it
or
result=[result; x_new]
%.............^

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!