필터 지우기
필터 지우기

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 CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by