Why does isfield return unexpected results for a FINTS object?
1 view (last 30 days)
Show older comments
MathWorks Support Team
on 12 Sep 2014
Edited: MathWorks Support Team
on 27 Feb 2015
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
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
0 Comments
More Answers (0)
See Also
Categories
Find more on Manage Products in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!