vishwa joshi
vishwa joshi

Reputation: 19

how to do average in csv file in matlab

Is there any function in matlab which automatically do average of data stored in csv file and store that average value in other csv file. this is my data stored in csv file

156.465902
416.337235
113.321306
88.751015
816.503289
104.757462
99.555698
210.75769
79.555543
131.261252
327.92057
120.064075
94.364211
167.277443
84.036572
188.522951
599.428593
275.750197
246.108917
1477.377321
140.480201

Upvotes: 0

Views: 258

Answers (1)

sgarizvi
sgarizvi

Reputation: 16796

You can use dlmread and dlmwrite to achieve what you want.

values = dlmread('input_file.csv');
m = mean(values(:));
dlmwrite('output_file.csv', m);

You can also append the value to output file like this:

dlmwrite('output_file.csv', m, '-append');

Upvotes: 6

Related Questions