Concatenating data from a variable within a MAT file in a loop
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!