hourly mean - why do I get the following error

3 views (last 30 days)
Hi,
I want to perform the hourly mean of my data time series. However whenever I try, and following the matlab example, I got the following error
Error using timetable/retime (line 139)
Applying the function 'mean' to the 1st group in the variable 'Temp' generated the following error:
Matrix dimensions must agree.
When I then tried the example provided by Matlab, I got the same error;
>> Time = [minutes(0):minutes(15):minutes(105)]';
Temp = [98;97.5;97.9;98.1;97.9;98;98.3;97.8];
Pulse = [80;75;73;68;69;65;72;71];
TT = timetable(Time,Temp,Pulse)
TT =
8×2 timetable
Time Temp Pulse
_______ ____ _____
0 min 98 80
15 min 97.5 75
30 min 97.9 73
45 min 98.1 68
60 min 97.9 69
75 min 98 65
90 min 98.3 72
105 min 97.8 71
>> TT2 = retime(TT,'hourly','mean')
Error using timetable/retime (line 139)
Applying the function 'mean' to the 1st group in the variable 'Temp' generated the following error:
Matrix dimensions must agree.
can you tell me why do I get such error?? thanks so much in advance

Answers (1)

Star Strider
Star Strider on 24 Jun 2019
The problem may be that you’re running your code in the Command Window.
When I run it in a script, it runs without error and produces:
TT2 =
2×2 timetable
Time Temp Pulse
______ ______ _____
0 min 97.875 74
60 min 98 69.25
Run it in a script and see if you get the same error. I would be surprised if you would.
  2 Comments
Star Strider
Star Strider on 24 Jun 2019
windyana07’s Answer mved here:
it doesnt for me... and I get the following issue...
Warning: A value of class "matlab.internal.editor.eval.TempFolder" was indexed with no
subscripts specified. Currently the result of this operation is the indexed value
itself, but in a future release, it will be an error.
Star Strider
Star Strider on 24 Jun 2019
I have no idea what is throwing that error.
Use the telephone handset icon in the upper right corner of this page and the Contact Us link to ask MathWorks for help.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!