I have read data from an excel sheet. The data Iam trying to manipulate is in the second column. First line is the header. i would like to extract last 4 characters of each content.
D = dta_txt(2:end,2);lastFourChar = cell(length(D),1);chArr = char(D);for i = 2:length(D)oneString = chArr(i,:);trimmedString = strtrim(oneString);lastFourChar(i) = cellstr( trimmedString( length(trimmedString)-3 : length(trimmedString) ));% check if last 4 characters contain '/' and extract those data alone from dta_txt
end
I request help to the improve the above code using cellfun and anonymous function. Also I would like to know how to check for presence of '/' and extract appropriate data from the cell array dta_txt if the check returns 1.
Thank You !
Best Answer