How do I override the LENGTH function to support TABLE data type in MATLAB R2013b?

I have a function that takes in a generic variable 'x' and irrespective of its data type loops through each entry of its largest dimension. The table data type introduced in MATLAB R2013b however does not support this function and limits the reusability of my code. When 'x' is a TABLE I would like LENGTH(x) to return the height of the table.

 Accepted Answer

Currently it is not advisable to override the LENGTH function for TABLE data type. A possible workaround is be to include the function below in a folder inside MATLAB PATH and replace all instances of LENGTH with FINDLENGTH in your script.
function len = findlength (x)
if istable(x)
len = height(x);
else
len = length(x);
end
end

More Answers (0)

Categories

Products

Release

R2013b

Community Treasure Hunt

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

Start Hunting!