best way to import multiple sets of data?

1 Ansicht (letzte 30 Tage)
Emily Bell
Emily Bell am 19 Nov. 2015
I'm trying to import data from 26 separate files into the variables u and v, and I want 26 separate instances each of u and v (ie u_1 through u_26). In the files, u and v are 29x39 doubles. I tried the following code to create u and v as 3D arrays:
for k=1:26
filename = sprintf('Angle1-%d.mat', k);
data = load(filename);
u = zeros(29, 39, 26);
v = zeros(29, 39, 27);
u(:, :, k) = data.u;
v(:, :, k) = data.v;
This made sense to me conceptually but it didn't seem to work in practice - the whole array ended up being zeros except for the last set of 29x39. Is there a better way to import this data?

Antworten (0)

Kategorien

Mehr zu Structures 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!

Translated by