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

2 views (last 30 days)
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.

Accepted Answer

Bob Thompson
Bob Thompson on 4 Dec 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.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!