How to import multiple data from .csv and analyse them?

1 Ansicht (letzte 30 Tage)
Bianca Motfolea
Bianca Motfolea am 4 Dez. 2018
Beantwortet: Bob Thompson am 4 Dez. 2018
I have experimental data in 20 .csv files and I need to take a column from each of them to do the average and then to apply the formula and transform pressure in velocity. At the end I will need to plot everything.
I know how to do this for each of them but I don't know how to do a loop or something that woud give me the averages for the .csv filles at once.

Akzeptierte Antwort

Bob Thompson
Bob Thompson am 4 Dez. 2018
files = dir('Your file directory'); % I suggest adding a *.csv to this to only get the .csv files.
for i = 1:length(files)
raw = csvread(files(i).name);
data(:,i) = raw(:,1); % Pick your column.
end
ave = mean(data); % Gives mean values of each set of data. Adjust as desired.
This is the basic structure I use for these types of things. Adjust as needed.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Produkte


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by