import multiple files with for loop

4 views (last 30 days)
Hello, i need to know how can i do this with a double for loop,
sza10str2 = importdata("10.0_02_streams.out");
sza10str4 = importdata("10.0_04_streams.out");
sza10str8 = importdata("10.0_08_streams.out");
sza10str16 = importdata("10.0_16_streams.out");
sza30str2 = importdata("30.0_02_streams.out");
sza30str4 = importdata("30.0_04_streams.out");
sza30str8 = importdata("30.0_08_streams.out");
sza30str16 = importdata("30.0_16_streams.out");
i tried something like this but it doesn't woks.
Any suggestions?
Thank you..
x = [10.0 30.0];
y = [02 04 08 16];
for i = 1:2
for j=1:4
sza{i}streams{j} = importdata(sprintf('%d_%d_streams.out', x(i),y(j)));
end
end

Accepted Answer

Walter Roberson
Walter Roberson on 18 Dec 2019
sza{i,j} = importdata(sprintf('%.1f_%02d_streams.out', x(i),y(j)))

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!