Display just the first letters of a filename as String
4 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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 Exchange 中查找有关 File Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!