how to do same calculation for diffrent selected file

1 回表示 (過去 30 日間)
SANKAR JYOTI NATH
SANKAR JYOTI NATH 2016 年 11 月 3 日
編集済み: KSSV 2016 年 11 月 3 日
i have more than 50 .txt files , and each txt file contains some numerical values, and from that numerical values i have to do some calculation and have to find the result, the calculation part is already done, i am using 'uigetfile' to browse the files, the code is perfectly working when i select one txt file. but the problem is that i want to display the results for all file by selecting all file(ctrl+A)...i need a loop program through which selected files are execute automaticallyone by on..... some of my codes are here
folder_with_data = 'C:\Users\Parag\Desktop\newfof2\files';
file_path = uigetfile(fullfile(folder_with_data, '*.txt'), 'MultiSelect', 'on'); % browse for files
data = importdata(file_path); % Load the data
mkdir('C:\DeitY-SAMEER pjt_sankar\F2 and F1');
[pathstr,name,ext,versn] = fileparts(file_path);
dt=strcat('Date-',name(1:2),'/',name(4:5),'/',name(7:8));
tm=strcat('Time-',name(10:11),':',name(12:13),' ','LT');
idr=data;
Fr=idr(:,1);
Hr=idr(:,2);
Ar=idr(:,3);
Fr=Fr./1000000;

回答 (1 件)

KSSV
KSSV 2016 年 11 月 3 日
編集済み: KSSV 2016 年 11 月 3 日
clc; clear all ;
F = dir('*.txt'); % get all text files
nF = length(F) ; % total number of files
% loop for each file
for ii = 1:nF
fname = F(ii).name ; % present file name
%%do what you want
end

カテゴリ

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