Azzera filtri
Azzera filtri

Input file editing format

2 visualizzazioni (ultimi 30 giorni)
RAKESH KUMAR TOTA
RAKESH KUMAR TOTA il 20 Gen 2021
Hi, Good morning
I have a text file el.txt which contains 4800 lines . I need to change linesand store in same text file or create a new file which ever it is fine according to user requirement for instance line 1,121,241,361,481,601 , 721,841,961,1081,1201,1321,1441,1561,1681,1801,.....so on to 4681. difference of 120 lines betweeen lines and next starts with line 2,122,242,361..... 4681.... thand next 3,123,243......it contines till 4800 lines. in this sequesnce lines to be stored in text file. Any help in this direction is appreciated. Thank you in advance.
  2 Commenti
Bob Thompson
Bob Thompson il 20 Gen 2021
How much of this process do you have so far? Is there a specific issue you're running into, or not sure how to do any of it in Matlab?
RAKESH KUMAR TOTA
RAKESH KUMAR TOTA il 20 Gen 2021
I dont know how to do it in matlab .

Accedi per commentare.

Risposta accettata

Mathieu NOE
Mathieu NOE il 20 Gen 2021
hello
I believe this code should work - I tested it only with loops = 2 even though I think you need to go up to 120
data = importdata('el.txt');
[m,n] = size(data);
loop = 2
% option 1 : split and save as separate files
for ci = 1:loop
ind = ci:120:m;
data_out = data(ind,:);
filename = ['data' num2str(ci) '.txt'];
writematrix(data_out, filename);
end
% option 2 : or stack vertically and save as one files
data_all = [];
for ci = 1:loop
ind = ci:120:m;
data_out = data(ind,:);
data_all = [data_all;data_out];
end
filename = ['data' num2str(ci) '.txt'];
writematrix(data_all, 'data_stacked.txt');

Più risposte (0)

Categorie

Scopri di più su Reporting and Database Access in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by