Receive an error when using an empty string array input in the "strrep" function.
显示 更早的评论
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"?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!