how can I remove 4 character of a string?
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
for example string is LASTNAME ,output=NAME
0 Kommentare
Antworten (2)
KALYAN ACHARJYA
am 20 Nov. 2018
Bearbeitet: KALYAN ACHARJYA
am 20 Nov. 2018
s='lastname';
modified_s=s(5:end);
%Command Window
>> s='lastname'
>> modified_s=s(5:end)
s=lastname
modified_s=name
1 Kommentar
Jan
am 20 Nov. 2018
s(5:end) can be interpreted as: Keep the last part. This is the same as removing the leading 4 characters:
s = 'lastname';
s(1:4) = [];
John Cunningham
am 26 Aug. 2021
If s needs to be a string, just convert to character, grab the indices you need, then convert back to string.
K>> s = "lastname";
K>> s = char(s);
K>> s = string(s(5:end))
s =
"name"
Siehe auch
Kategorien
Mehr zu String Parsing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!