how to make it into for loop
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I am trying to make the below cose into a for loop
Would you help me with that?
file1=load('0.txt','-ascii');
a=file1(:,1);
b=file1(:,2)-r_peak1(1)/1000;
c=file1(:,3);
data=[a,b,c];
save('0.txt','data1','-ascii');
file2=load('3.txt','-ascii');
a=file2(:,1);
b=file2(:,2)-r_peak1(2)/1000;
c=file2(:,3);
data=[a,b,c];
save('3.txt','data1','-ascii');
file3=load('6.txt','-ascii');
a=file3(:,1);
b=file3(:,2)-r_peak1(3)/1000;
c=file3(:,3);
data=[a,b,c];
save('6.txt','data1','-ascii');
file4=load('9.txt','-ascii');
a=file4(:,1);
b=file4(:,2)-r_peak1(4)/1000;
c=file4(:,3);
data=[a,b,c];
save('9.txt','data1','-ascii');
Thank you
0 Kommentare
Akzeptierte Antwort
Jan
am 21 Apr. 2021
Bearbeitet: Jan
am 21 Apr. 2021
iPeak = 0; % [EDITED]
for k = [0, 3, 6, 9]
name = sprintf('%d.txt', k);
data = load(name, '-ascii');
iPeak = iPeak + 1;
a = data(:,1);
b = data(:,2) - r_peak1(iPeak) / 1000;
c = data(:,3);
data = [a, b, c];
save(name, 'data', '-ascii');
end
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Startup and Shutdown 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!