Explanation

Dividing a string into multiple elements by calling strtok in a while loop can be inefficient, especially if multiple calls to strtok are made. Generally, using one call to split is clearer and faster.


Suggested Action

Replace the while loop that includes the call to the strtok function with a single call to the split function. For example, if you have this code that calls the strtok function in a while loop:

while ~isempty(remain)
    [token,remain]=strtok(remain, delimiter);
end

Replace the code with a single call to the split function.

tokens = split(str,delimiter)