replace dlmread file name with a variable in a loop
Ältere Kommentare anzeigen
I have around 20 files needed to be read and plotted. So the file names are such as file.288.10 , file.288.100 etc. I have 20 files. I am tryng in the following code, but its not reading T and P.
for T = [288 299 308 323 337]
for P = [10 100 340 544]
M = dlmread('file.T.P', ' ', 1, 0);
figure
plot (M(:,1), M(:,2))
hold on
plot (M(:,1), M(:,3))
hold on
end
end
Akzeptierte Antwort
Weitere Antworten (2)
dpb
am 12 Jun. 2022
You've got to turn the numerics into string filename to build dynamically --
for T = [288 299 308 323 337]
for P = [10 100 340 544]
fname=sprintf('file%d.%d',T,P);
M = dlmread(fname,' ', 1, 0);
figure
plot (M(:,1), M(:,2:3))
end
end
Avik Mahata
am 12 Jun. 2022
0 Stimmen
Kategorien
Mehr zu Environment and Settings finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!