Вопрос

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]

Это было полезно?

Решение

You cannot save a string in an array.

Use

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

Or save it in a cell.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top