Receive an error when using an empty string array input in the "strrep" function.
Show older comments
When I use an empty string array as any of the three inputs to the "strrep" function, the function output is different in comparison to the "replace" function. However, their respective documentation pages appear to describe the same functionality.
As a particular example, when I try to run the following MATLAB code using the "strrep" function, I receive the following error message:
strrep(strings(1,0),["A","B"],["C","D"])
Error using strrep
All nonscalar inputs must be the same size.
However, if I use exactly the same input arguments for the "replace" function, there is no error message:
replace(strings(1,0),["A","B"],["C","D"])
ans =
1×0 empty string array
Is there a workaround to avoid this error message appearing when using "strrep"?
Accepted Answer
More Answers (0)
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!