Creation of a text file with a series of record set

2 visualizaciones (últimos 30 días)
Chandra Bhushan
Chandra Bhushan el 25 de Jul. de 2019
Editada: per isakson el 25 de Jul. de 2019
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

Respuesta aceptada

per isakson
per isakson el 25 de Jul. de 2019
Editada: per isakson el 25 de Jul. de 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

Más respuestas (0)

Categorías

Más información sobre Text Data Preparation en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by