Problem 171. Reverse the Words (not letters) of a String
Solution Stats
Problem Comments
-
1 Comment
Eagle wangzhaowu
on 18 Apr 2020
s2='';
s1=[' ',s1];
a=findstr(s1,' ');
a=[a length(s1)];
for i=length(a):-1:2
s2= strcat(s2,s1(a(i-1):a(i)));
end
s2(:,1)=[];
Problem Recent Solvers330
Suggested Problems
-
Back to basics 6 - Column Vector
976 Solvers
-
Back to basics 9 - Indexed References
408 Solvers
-
Back to basics 21 - Matrix replicating
1186 Solvers
-
Construct an index vector from two input vectors in vectorized fashion
265 Solvers
-
282 Solvers
More from this Author56
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!