- The input data is that a text file? Or double array? Or a cell array?
- " are several observations of travel times per day" does that mean that the length of the lines/row varies?
Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
How to aggregate data and calculate its standard deviation
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi
I have two matrix with 1) day 2) travel time (sec). Where there are several observations of travel times per day. And date for more than two years.
day .......Traveltime
1 .............220
1 .............230
1 .............240
2 .............210
2 .............210
...etc
How can I aggregate the data_, so that I will have only one observation (average travel time) per day, and the standard deviation for each day.
So that the output, will be something like this:
day.......average_time.......Std_dev
1............230.............10
2............210.............0
I would appreciate if you can help me.
댓글 수: 2
per isakson
2013년 7월 8일
편집: per isakson
2013년 7월 8일
Firstly, a couple of questions:
답변 (1개)
dpb
2013년 7월 8일
편집: dpb
2013년 7월 8일
I'll presume you have two vectors d and t; if so you can make a matrix as
MATl
>> m = [d t]
m =
1 220
1 230
1 240
2 210
2 210
>> [u,~,c] = unique(m(:,1)); % get the unique days, locations
>> [u,accumarray(c,m(:,2),[],@mean),accumarray(c,m(:,2),[],@std)]
ans =
1 230 10
2 210 0
>>
Or, of course, you can use the two vectors directly w/o the concatenations...
MATL
>> [u,~,c] = unique(d);
>> [u,accumarray(c,t,[],@mean),accumarray(c,t,[],@std)]
ans =
1 230 10
2 210 0
>>
Why didn't just use them first time is beyond me... :)
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!