Why does isfield return unexpected results for a FINTS object?

1 view (last 30 days)
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

MathWorks Support Team
MathWorks Support Team on 27 Feb 2015
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

Find more on MATLAB in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

No release entered yet.

Community Treasure Hunt

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

Start Hunting!