Display just the first letters of a filename as String

11 ビュー (過去 30 日間)
Niklas Reinshagen
Niklas Reinshagen 2020 年 6 月 18 日
コメント済み: Niklas Reinshagen 2020 年 6 月 21 日
Hey I wan't to display just the first four letters from the file... lets say: TestFile_18.06.2020.txt so Matlab displays just "Test".
Is there any short possibility to make this happen? It should be integraded into a script later.
Best Regards
Niklas

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 6 月 18 日
編集済み: Ameer Hamza 2020 年 6 月 19 日
If it is stored in a variable as a char array, then you can simply use indexing
x = 'TestFile_18.06.2020.txt';
disp(x(1:4))

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by