how to do same calculation for diffrent selected file

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by