The variable "NEWSST_2015" is not defined properly it seems, probably has to do with how time is indexed.. Could you please suggest how to index time here? The .mat file used is attached.
%% convert from daily to weekly (8-day) averages
load NEWSST_2015.mat
% Convert data into timetable
NEWSST_2015 = datetime(NEWSST_2015);
NEWSST_2015 = table2timetable(NEWSST_2015);
% Create time vector (8-day duration)
t = NEWSST_2015(1);
startTime = datetime(t.Year,t.Month,t.Day,t.Hour,0,0);
time = (startTime:days(8):NEWSST_2015(end))';
% Resampling
NEWSST_2015_2 = retime(NEWSST_2015,time,'linear');

 채택된 답변

Adam
Adam 2019년 3월 19일
편집: Adam 2019년 3월 19일

0 개 추천

The variable in your mat file is called NEWSST, not NEWSST_2015.
It is usually better though to load a mat file into a struct and then reference from that e.g.
loadedData = load( 'NEWSST_2015.mat' );
NEWSST_2015 = loadedData.NEWSST;
then you will have a variable of the name you use. I haven't checked if the rest of your code is fine, but the variable not existing is certainly the main problem.

댓글 수: 3

Good point about NEWSST.
I have implemented it like this though and run it:
%% convert from daily to weekly (8 day) averages
loadedData = load( 'NEWSST_2015.mat' );
NEWSST_2015 = loadedData.NEWSST; % Convert data into timetable
NEWSST_2015 = datetime(NEWSST_2015);
NEWSST_2015 = table2timetable(NEWSST_2015); % turn table into a timetable
% Create time vector (8-day duration)
t = NEWSST_2015(1);
startTime = datetime(t.Year,t.Month,t.Day,t.Hour,0,0);
time = (startTime:days(8):NEWSST_2015(end))';
% Resampling
NEWSST_wavg = retime(NEWSST_2015,time,'linear');
and now i get these consecutive errors:
Error using datetime (line 588)
Numeric input data must be a matrix with three or six columns, or else three, six, or seven separate numeric arrays. You can also create datetimes from a single numeric array using the 'ConvertFrom' parameter.
Error in sst_test (line 31)
NEWSST_2015 = datetime(NEWSST_2015);
Error using table2timetable (line 43)
First argument must be a table.
Error in sst_test (line 32)
NEWSST_2015 = table2timetable(NEWSST_2015); % turn table into a timetable
Error using datetime (line 588)
Numeric input data must be a matrix with three or six columns, or else three, six, or seven separate numeric arrays. You can also create datetimes from a single numeric array using the 'ConvertFrom' parameter.
Error in sst_test (line 32)
NEWSST = datetime(NEWSST);
Pretty confused !
Adam
Adam 2019년 3월 19일
I don't use datetime, but the error message seems very clear in what it expects. You give it a 3-dimensional array which does not conform in any way to those expectations.
Denk
Denk 2019년 3월 19일
Thank you for your comments and time.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2019년 3월 19일

댓글:

2019년 3월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by