フィルターのクリア

How to extract certain files according to numbers in the filename?

2 ビュー (過去 30 日間)
Yasmin Samy
Yasmin Samy 2019 年 8 月 8 日
コメント済み: Yasmin Samy 2019 年 8 月 11 日
Hello,
So i have files with names as shown below:
bar_3pressure.xlsx
bar_3temp.xlsx
bar_4pressure.xlsx
bar_4temp.xlsx
this goes on..where the numbers represent months. I have a loop which requires i read the files for each month to perform certain calculations. Each iteration being a separate month. So first i would do the calculations for march (using only bar_3press..and bar_3temp.xlsx), next iteration april (using only bar_4pressure and bar_4temp)etc. How can i change the input files accordingly? As in how can i specify the file name that is being read.
thanks!

採用された回答

Adam Danz
Adam Danz 2019 年 8 月 8 日
編集済み: Adam Danz 2019 年 8 月 9 日
n = 3; % for month #3
filename = sprintf('bar_%dpressure.xlsx', n)
Result
filename =
'bar_3pressure.xlsx'
  1 件のコメント
Yasmin Samy
Yasmin Samy 2019 年 8 月 11 日
Thank you ! That's what i was looking for!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

製品


リリース

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by