Opposite to horzcat?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
How do I subtract a part of a string? i.e the opposite functionality of horzcat. Say that I have a string = 'textstring' and I want to subtract string so that I get string2 = 'text'.
1 Kommentar
Stephen23
am 7 Mär. 2016
Bearbeitet: Stephen23
am 7 Mär. 2016
Keep in mind that there is no such thing as the opposite of concatenation given just one string as an input, because by concatenating you lose information (i.e. the lengths of the parts). The only way to truly perform the opposite operation to concatenation requires that you store the part lengths as well as the concatenated string.
Antworten (3)
Walter Roberson
am 7 Mär. 2016
Strings are row vector of char, so index the vectors.
string2 = string(1:4);
3 Kommentare
Torsten
am 7 Mär. 2016
string2 = string(1:end-characters_to_be_removed_from_the_end);
Best wishes
Torsten.
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!