필터 지우기
필터 지우기

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