Writing a function that can take a financial time series or a vector

1 次查看(过去 30 天)
I am new to Matlab, and I trying to write a function that can accept either a financial time series or a vector. Something like:
function y = mydiff(x)
if istimeseries(x)
vec = fts2mat(x.CLOSE);
else
vec = x;
end
y = diff(vec);
end
I'm at a loss, however, on what to put in place of the istimeseries test. Is this possible?
Thanks in advance for the help.

采纳的回答

Rick Rosson
Rick Rosson 2012-3-25
if isa(x,'timeseries')
...
else
...
end
  1 个评论
Doug
Doug 2012-3-25
That worked like a charm. For the record, the class for a financial time series appears to be 'fints' and not 'timeseries' as I had assumed.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by