フィルターのクリア

how to modify data values for multiple text files

2 ビュー (過去 30 日間)
Vidhyashankar V
Vidhyashankar V 2020 年 8 月 18 日
編集済み: per isakson 2020 年 8 月 19 日
I want to modify the values for multiple text files at the same time how do i do that.
pathname = 'C:\Users\Documents\Shank\Onedrive\MATLAB\2017\2017-07'; % in the folder specified.
files = dir(fullfile(pathname, '*.txt' , ' ReadFcn' , @importdata)); % Get full path names for each text file
numFiles = fullfile({files.folder}, {files.name}); % Get a list of all txt files in the current folder, or subfolders of it.
for k=1:31 %there are 31 .txt files inside 2017-07
filename=sprintf('[208] 2017-07-01%d.txt',k);
T{1:1440,2:38}(T{1:1440,2:38}==0) = NaN; %change athh the zeroes and negative values to NaN
T{1:1440,2:38}(T{1:1440,2:38} < 0) = NaN;
end
there are 31 files and in each file the zeroes and negativs numbers should be changed to NaN. I tried for 1 file how do fo this for 31 .txt files and save them .
Ps. there are 31 folders each folder with 31 files .

採用された回答

KSSV
KSSV 2020 年 8 月 18 日
txtFiles = dir("*.txt") ;
N = length(txtFiles) ;
for i = 1:N
thisFile = txtFile(i).name ;
% do what you want
end
  1 件のコメント
Vidhyashankar V
Vidhyashankar V 2020 年 8 月 19 日
i figured it out thanks !

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFiles and Folders についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by