Creation of a text file with a series of record set

조회 수: 2 (최근 30일)
Chandra Bhushan
Chandra Bhushan 2019년 7월 25일
편집: per isakson 2019년 7월 25일
I want to give Number of record as N= 100 so that , in a txt file the follwing tempates is written 100 times by automatcially
changing the corresponding serial numbers for the values of each item.
The sample one record is as below:
One Sample
********************************************************
Patient ID : H00001
Patient Name : Name00001
Hospital Name : Hos001
Reffered By : Dr. Doctor001
Diease Symptom : Diease001
Remark : He is Suffereing from Diease 001

채택된 답변

per isakson
per isakson 2019년 7월 25일
편집: per isakson 2019년 7월 25일
Try
cssm1()
dbtype test.txt 1:14
where
function cssm1()
fid = fopen( 'test.txt', 'w' );
assert( fid >= 3 )
for jj = 1 : 100
fprintf( fid, '********************************************************\n');
fprintf( fid, 'Patient ID : H00%03d\n', jj );
fprintf( fid, 'Patient Name : Name00%03d\n', jj );
fprintf( fid, 'Hospital Name : Hos%03d\n', jj );
fprintf( fid, 'Reffered By : Dr. Doctor%03d\n', jj );
fprintf( fid, 'Diease Symptom : Diease%03d\n', jj );
fprintf( fid, 'Remark : He is Suffereing from Diease %03d\n', jj );
end
fclose( fid );
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Text Data Preparation에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by