I have 60 different character arrays loaded in my workspace (Book01, Book02, ..., Book60). For example, Book01 is a 1x202040 char.
I'm working in a script file, and trying to separate the last sentence("RandomInfoAtEnd") of Book45 until Book58:
WholeBook = Book50; % Call Array for test
for i = 1:60
book = eval(['Book' num2str(i)]);
if i >= 45 && i <= 58
% Procedure to separate last sentence.
Chr = convertStringsToChars(WholeBook);
SearchedUnit = '.!?' ; % Sentence end punctuation
idx = ismember (Chr, SearchedUnit);
Loc = find (idx, 2, 'last'); % Find second last sentence-ending-punctuation
if numel (Loc) < 2
error ('the requested character cannot be found')
end
SecondLastLocation = Loc (1);
AllLocations = find (idx);
RandomInfoAtEnd = extractAfter(WholeBook,SecondLastLocation);
else
RandomInfoAtEnd = ''; % No sentence separated
end
end
Right now I have a problem only with the IF-statement or FOR-loop logic, in such a way that RandomInfoAtEnd = ''
for any array that is called.
My procedure is working fine, as it separated the last sentence perfectly from any array, but what am I doing wrong with the FOR-loop/IF-statement
?
Thanks.
question from:
https://stackoverflow.com/questions/65643656/matlab-perform-a-procedure-only-for-specific-character-arrays 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…