MATLAB Object-Oriented Programming

(Joyce) #1

methods (Static = true)
function [x,y] = grid(lim)
inc = (lim(2)-lim(1))/20;
[x,y] = meshgrid(lim(1):inc:lim(2));
end % grid


function isOk = isSuitable(funcH)
v = [1 1;1 1];
try
funcH(v,v);
catch %#ok
me = MException('DocExample:fcneval',...
['The function ',func2str(funcH),' Is not a suitable F(x,y)']);
isOk = me;
return
end
if isscalar(funcH(v,v));
me = MException('DocExample:fcneval',...
['The function ',func2str(funcH),' Returns a scalar when evaluated']);
isOk = me;
return
end
isOk = [];
end


end


end


@fcnview/fcnview.m Class Code


classdef fcnview < handle
properties
FcnObject % fcneval object
HAxes % subplot axes handle
HLUpdateGraph % UpdateGraph listener handle
HLLm % Lm property PostSet listener handle
HEnableCm % "Listen" context menu handle
HDisableCm % "Don't Listen" context menu handle
HSurface % Surface object handle
end


methods
function obj = fcnview(fcnobj)
if nargin > 0
obj.FcnObject = fcnobj;
obj.createLisn;
end
end


Techniques for Using Events and Listeners
Free download pdf