필터 지우기
필터 지우기

How to delete the first or the first two characters in a string?

조회 수: 229 (최근 30일)
Philipp Mueller
Philipp Mueller 2020년 5월 15일
답변: the cyclist 2022년 4월 28일
Hello,
How can i delete the first two characters of this string? Thank you
string='W987';

채택된 답변

KSSV
KSSV 2020년 5월 15일
편집: KSSV 2020년 5월 15일
string(1:2) = [] % To remove the firt two elements

추가 답변 (1개)

the cyclist
the cyclist 2022년 4월 28일
In modern MATLAB parlance, 'W987' is a character array, not a string.
@KSSV's answer is accurate in your case, but will not work on the string "W987". The following will work for either a character array or a string:
c = 'W987';
eraseBetween(c,1,2)
ans = '87'
s = "W987";
eraseBetween(s,1,2)
ans = "87"

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by