Undefined function 'diff' for input arguments of type 'table'

5 views (last 30 days)
Dear Members,
I am facing following error when running my MATLAB code. Please advice the solution for this.
>> ind1=find( diff(daily_stk(:,2)) ~= 0 ); % row number
Undefined function 'diff' for input arguments of type 'table'.
daily_stk.Properties
ans =
TableProperties with properties:
Description : ''
UserData : []
DimensionNames : {'Row' 'Variables'}
VariableNames : {'yyyy' 'mm' 'dd' 'vwretd'}
VariableDescriptions : {}
VariableUnits : {}
VariableContinuity : []
RowNames : {}
CustomProperties : No custom properties are set.
Use addprop and rmprop to modify CustomProperties.

Accepted Answer

Guillaume
Guillaume on 7 Sep 2019
Edited: Guillaume on 7 Sep 2019
As I've told you already, read the documentation, in particular Access data in tables.
As explained on that page, () indexing returns a table. You want the content of the table which you can access with
daily_stk{:, 2}
or
daily_stk.(2)
or better
daily_stk.mm
so,
rowindex = find(diff(daily_stk.mm) ~= 0)

More Answers (0)

Categories

Find more on Tables 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!