Why does isfield return unexpected results for a FINTS object?

Creating a FINTS object and then using the isfield method to check for the existence of the field 'times' returns unexpected results. The following code illustrates the behavior:
 
data = [1:6]';
dates = [today:today+5]';
tsobjkt = fints(dates, data);
fieldnames(tsobjkt)
ans =
'desc'
'freq'
'dates'
'series1'
isfield(tsobjkt,'times')
ans =
1

 Accepted Answer

This is a known limitation of MATLAB. 
A workaround is to check the output of the "fieldnames" function for the string 'times' using "strcmp" instead:
 
data = [1:6]';
dates = [today:today+5]';
tsobjkt = fints(dates, data);
fieldnames(tsobjkt)
ans =
'desc'
'freq'
'dates'
'series1'
isfield(tsobjkt,'times')
ans =
1
any(strcmp(fieldnames(tsobjkt),'times'))
ans =
0
 

More Answers (0)

Categories

Products

Release

No release entered yet.

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!