Concatenating data from a variable within a MAT file in a loop
Show older comments
Within a loop, I want to 1) load a variable from a MAT file, 2) concatenate the newly loaded two-column data of varying lengths to a new variable array, and 3) save the variable to a new MAT file. I am fairly new to Matlab, but while I know how to add values to a given vector/array within a loop, this question has vexed me. Any suggestions?
EXAMPLE:
a=[load('fileA.mat','delta_length')];
b=[load('fileB.mat','delta_length')];
c=[load('fileB.mat','delta_length')];
new = [a.delta_length; b.delta_length; c.delta_length];
save('fileABC.mat','new');
In the above example, this is how I am doing it line by line, but the number of files I want to load could range from 1 to 10 or higher.
With my limited understanding I am trying something like this:
new=[];
for i=1:3
a_i=[load('fileA.mat','delta_length')];
new = [a_i.delta_length; ??how to keep appending a vector here??];
end
save('fileABC.mat','new');
Hopefully it's clear from this what I am trying to do. Any help much appreciated!
-Jason
Accepted Answer
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!