Question

for i = 1:2

data2=fopen(strcat('DATA\PRE-PROCESS_DATA\F22_TR\f22_TR_pdata_',int2str(i),''),'r')
CharData = fread(data2, '*char')';  %read text file and store data in CharData
fclose(data2);

age = regexp(CharData,'(\d{4})','match','once')

end

file : f22_TR_pdata_1 --> Registered On June 24, 1997

file : f22_TR_pdata_2 --> Registered On March 29, 1997

Age:1997

How do i store both of that like Age= [1997 1997]

Was it helpful?

Solution

You cannot save a string in an array.

Use

age(i) = str2double(regexp(CharData,'(\d{4})','match','once')).

Or save it in a cell.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top