필터 지우기
필터 지우기

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 CenterFile Exchange에서 Reporting 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