Borrar filtros
Borrar filtros

Load multiple files on MATLAB

4 visualizaciones (últimos 30 días)
Alakesh Upadhyaya
Alakesh Upadhyaya el 21 de Feb. de 2023
Respondida: Voss el 21 de Feb. de 2023
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 ?

Respuesta aceptada

Voss
Voss el 21 de Feb. de 2023
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

Más respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by