Undoing a strsplit function
Show older comments
is there a way to reverse the strsplit at the end of a loop?
3 Comments
Scott MacKenzie
on 23 Apr 2021
Edited: Scott MacKenzie
on 23 Apr 2021
What do you mean by "end of a loop"? What loop? If you just want to reverse the order of the elements produced by strsplit, use flip:
>> s = 'a,bc,def,g'
s =
'a,bc,def,g'
>> z = strsplit(s,',')
z =
1×4 cell array
{'a'} {'bc'} {'def'} {'g'}
>> flip(z)
ans =
1×4 cell array
{'g'} {'def'} {'bc'} {'a'}
Walter Roberson
on 23 Apr 2021
strjoin()
Edward Jia Sheng Lim
on 24 Apr 2021
Answers (1)
Jan
on 23 Apr 2021
0 votes
The easiest way is to store a copy of the original data. Then nothing has to be undone.
Categories
Find more on Loops and Conditional Statements 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!