How do I create an array of one column and several lines with only a few characters from the name of my files?

3 ビュー (過去 30 日間)
I have several files with this structure. At each loop, a file is opened and I would like to write the first 5 characters of the file name in a column. How can I do this?
Example:
03000_20200506_0300.dat
04000_20200506_0300.dat
05000_20200506_0300.dat
06000_20200506_0300.dat
The matrix I would like to obtain:
03000
04000
05000
06000
...
Thanks.

採用された回答

KSSV
KSSV 2020 年 8 月 25 日
編集済み: KSSV 2020 年 8 月 25 日
name = "03000_20200506_0300.dat";
s = strsplit(name,'_') ;
s{1}
Or
name = "03000_20200506_0300.dat";
name(1:5)
  3 件のコメント
KSSV
KSSV 2020 年 8 月 25 日
alt{j,1}=km ;
You have to save them into a cell.
pink flower
pink flower 2020 年 8 月 25 日
Thank you very much! This worked for me!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDebugging and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by