Creation of a text file with a series of record set
2 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
per isakson
on 25 Jul 2019
Edited: per isakson
on 25 Jul 2019
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 Comments
More Answers (0)
See Also
Categories
Find more on Text Data Preparation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!