필터 지우기
필터 지우기

Load multiple files on MATLAB

조회 수: 4 (최근 30일)
Alakesh Upadhyaya
Alakesh Upadhyaya 2023년 2월 21일
답변: Voss 2023년 2월 21일
So I have 10 data files and each data file contains X-cordinate and Y-cordinate of a ball for 100 frames.
The name of my files are like exp1.dat, exp2.dat, exp3.dat and so on till exp10.dat.
All of these files contain 2x100 data.
I have a code that calculates the velocity autocorelation of the ball for 100 time frames using the X and Y-cordinate.
What I want is to know how to write a code so that I can have a loop to load these files in sequence and caluclate the VACF for each of these data files and find mean of all 10 VACF ?

채택된 답변

Voss
Voss 2023년 2월 21일
n_files = 10;
VACF_all = zeros(n_files,100); % Pre-allocate a matrix to store all the VACF results.
% I assume the VACF you calculate for each file is a 1x100 vector (no idea if that's true)
for ii = 1:n_files
file_name = sprintf('exp%d.dat',ii);
% ...
% load the file, calculate VACF
% ...
VACF_all(ii,:) = VACF; % store VACF as the ii-th row of VACF_all
end
mean_VACF = mean(VACF_all, 1); % take the mean of all 10 VACFs

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by