I am writing here some portion of my code.
for i=1:size(files_hea,1) fid = fopen(files_hea(i).name, 'r'); scan_hea(i)= textscan(fid,... '%s','delimiter','\n','whitespace',''); scan_file=scan_hea{i}; id=char(scan_file(1,:)); Pat(i).id=id(1:9); age=char(scan_file(17,:)); Pat(i).age=age(8:end); sex=char(scan_file(18,:)); Pat(i).sex=sex(7:end); date=char(scan_file(19,:)); Pat(i).date=date(13:end); reason=char(scan_file(21,:)); Pat(i).reason=reason(24:end); acute_mi=char(scan_file(22,:)); Pat(i).acute_mi=acute_mi(35:end); former_mi=char(scan_file(23,:)); Pat(i).former_mi=former_mi(36:end); additional=char(scan_file(24,:)); Pat(i).additional=additional(24:end); scan_file=[];fid = fclose(fid);end
The above code create a structure like this
>> PatPat = 1x536 struct array with fields: id age sex date reason acute_mi former_mi additional
My doubt is, I want to save the data 'Pat' into an excel sheet. In that excel sheet it have to show
colourns like this
id age sex date reason acute_mi former_mi additional1 60 m 1999 mi yes no -2 58 f 1998 mi no yes yes 3. . .. . .. .
How to do it in matlab ?
Best Answer