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

financial time seriesFinancial Toolboxvector

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.

Best Answer

if isa(x,'timeseries')
...
else
...
end