フィルターのクリア

Loading Files of Similar Names into Script

3 ビュー (過去 30 日間)
Articat
Articat 2019 年 10 月 17 日
編集済み: KostasK 2019 年 10 月 17 日
So I have 7 files labeled the following:
Run1S01_TPIV, Run1S02_TPIV, Run1S03_TPIV,.... all the way up to Run1S07_TPIV.
I have already converted them to matlab files so their file name is ".mat"
Is there a way I can read all these files in doing a loop? Instead of giving them individual names(run1_1 = Run1S01_TPIV.mat, run2_2 = Run1S02_TPIV.mat ...).
So far I loaded the path where the files are saved by doing the following:
LoadPath = 'D:\Testing\PackagedFiles\3-12-19';
I am not sure how to construct the loop. Anything would help! Thanks.
  1 件のコメント
Articat
Articat 2019 年 10 月 17 日
The goal would be to have them each individually named for manipulation later in the script.

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

採用された回答

KostasK
KostasK 2019 年 10 月 17 日
編集済み: KostasK 2019 年 10 月 17 日
Hi there,
Would the code below help? Essentially you can use sprintf function to create a cell array with all the file names that you want. Then you can choose each file name from the cell array either in another loop or in any other way that you want in order to call your files
str = 'Run1S0%d_TPIV.mat' ; % Generic File Name
n = 7 ; % Number of Files
FileNameC = cell(n, 1) ; % Preallocate (This line is not really neccessary for this example you can delete it if you wish)
for i = 1:n
FileNameC(i) = {sprintf(str,i)} ;% All Filenames that you want
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEntering Commands についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by