Clear Filters
Clear Filters

changing the way object are displayed (overloading openvar)

2 views (last 30 days)
Hi,
I've implemented a class in which I overloaded many basic function likes size, subsref, etc.
The problem is that when I open the class in the variable panel it calls my size and subsref functions which are slow. I want it to return a massage like can't display an object of size > 10.
I tried to create a m file overload.m and to override the builtin openvar function so when called with my object it would behave as desired, otherwise it would call the builtin function. It didn't work, not sure why.
function openvar(varname)
if isa(varnmae, 'MultiField')
disp("can't display object");
else
builtin('openvar', varname);
end
end
And when I try to open any variable I get
Error using openvar
Too many input arguments.
  2 Comments
Yong-Joo Kwon
Yong-Joo Kwon on 10 Jun 2020
Edited: Yong-Joo Kwon on 10 Jun 2020
function openvar(varname, varargin)
if strcmp(varnmae, 'MultiField')
disp("can't display object");
else
evalin('caller', ['openvar ' varname]);
end
end
Walter Roberson
Walter Roberson on 10 Jun 2020
openvar receives a variable name, and the poster wants to check whether the variable named is of specific type, not whether the variable itself has specific name.
evalin caller is going to resolve to the exact same openvar routine, since the user was operating in the context of the calling routine when they got to this function.

Sign in to comment.

Answers (0)

Categories

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