Info

This question is closed. Reopen it to edit or answer.

How to calculate mean of amplitudes from many time vs amplitude ascii text files

1 view (last 30 days)
Hello,,
I have 100 ascii text file in same format (names are R01.txt, R02.txt,.......R100.txt). Every file contains 2 colums with 9000 rows. First colum represents time(sec) and it is the same for 100 files also. Second colum represents amplitude values (in cm/sec). In the case of having no so much data file, I can do it. For example if I have 3 files, I can calculate the mean as following without any need of using for loop etc.:
data1=load ('R01.txt');
data2=load ('R02.txt');
data3=load ('R03.txt');
time=data1(:,1); %The same for every file
amp1=data1(:,2);
amp2=data2(:,2);
amp3=data3(:,2);
mean=(amp1(1:9000)+amp2(1:9000)+amp3(1:9000))/3;
plot(time,mean')
But now, I have 100 text files and I want to calculate the mean of amplitudes from all 100 text files. Then I can plot the result (amplitude versus time).
I will be glad if you can help about this script.
Thank you

Answers (1)

madhan ravi
madhan ravi on 11 Jan 2019
  1 Comment
seda
seda on 12 Jan 2019
thanks for your response, but it is not exactly solve my problem unfortunately,I want to calculate the mean values of all 100 amplitude vs time files and then get one waveform plot ( time vs mean of 100 trials). so how can I insert that calculation into the for loop as the link you send before?

Community Treasure Hunt

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

Start Hunting!