필터 지우기
필터 지우기

changing the way object are displayed (overloading openvar)

조회 수: 2 (최근 30일)
Or Nahir
Or Nahir 2018년 7월 8일
댓글: Walter Roberson 2020년 6월 10일
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
Yong-Joo Kwon
Yong-Joo Kwon 2020년 6월 10일
편집: Yong-Joo Kwon 2020년 6월 10일
function openvar(varname, varargin)
if strcmp(varnmae, 'MultiField')
disp("can't display object");
else
evalin('caller', ['openvar ' varname]);
end
end
Walter Roberson
Walter Roberson 2020년 6월 10일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by