how to do same calculation for diffrent selected file

1 view (last 30 days)
SANKAR  JYOTI NATH
SANKAR JYOTI NATH on 3 Nov 2016
Edited: KSSV on 3 Nov 2016
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;

Answers (1)

KSSV
KSSV on 3 Nov 2016
Edited: KSSV on 3 Nov 2016
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

Tags

Community Treasure Hunt

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

Start Hunting!