How do I average a data which runs on a cycle?
이전 댓글 표시
I have a data file that goes like -1 0.2 -0.5 0.15 0 0.143 0.5 0.122 1 0.1234 1 0.233 0.5 0.32 0 0.322 -0.5 1.22 -1 1.333 then cycle 2 which has same x values but different y values . the cylce continues for 100 times. i want to have a average of y values for each x values.so finally i have the average y value
채택된 답변
추가 답변 (1개)
Read your data into one big 100xN matrix D (e.g., using dlmread) and then use mean(D). Voila.
댓글 수: 4
DebiPrasad
2014년 11월 24일
Oh, I see. Is your example one actual line of your file? It does not contain x values -1.5 and 1.5. Are the x values always in the same order -1, -0.5, 0.5, 1, 1, 0.5, -0.5, -1? Then you can construct your Y matrix from the big data matrix D as
Y = [D(:, 2:2:10); D(:, 20:-2:12)];
and compute the mean as
mean(Y)
for values of a = -1:0.5:1;
If you need something else, please provide more information about the file; maybe you should post the file or the first, say, 10 lines.
DebiPrasad
2014년 11월 24일
Thorsten
2014년 11월 26일
But in your example you have only x values that run from -1 to 1 and back from 1 to -1. So what do the real data look like? Could you provide the file?
카테고리
도움말 센터 및 File Exchange에서 App Building에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!