フィルターのクリア

Input file editing format

2 ビュー (過去 30 日間)
RAKESH KUMAR TOTA
RAKESH KUMAR TOTA 2021 年 1 月 20 日
コメント済み: RAKESH KUMAR TOTA 2021 年 1 月 20 日
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 件のコメント
Bob Thompson
Bob Thompson 2021 年 1 月 20 日
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 2021 年 1 月 20 日
I dont know how to do it in matlab .

サインインしてコメントする。

採用された回答

Mathieu NOE
Mathieu NOE 2021 年 1 月 20 日
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');

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeReporting and Database Access についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by