Reduce string length after check, with one line

2 views (last 30 days)
Hello!
I would like to reduce a string length after a check on the length itself, with one command. Is it possible? Something like:
x=x(length(x)>5)(1:5)
Thank you!

Accepted Answer

Stephen23
Stephen23 on 27 Aug 2020
x = x(1:min(5,end))

More Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!