From: Matt J on 30 Jul 2010 11:02 "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <i2uo68$2q8$1(a)fred.mathworks.com>... > You can create a specialized array type with the behavior you want using the function down at the bottom of this post, which uses this FEX tool > > http://www.mathworks.com/matlabcentral/fileexchange/26611-on-the-fly-definition-of-custom-matrix-objects ========= Truthfully though, it would probably be better to build this by creating a subclass of the MATLAB double type, as down at the bottom. Then you could more easily inherit the other mathmetical operations +,-, etc... >> O=SpecialZeros(0); >> [O/O, 0/O, O+1,O*3, 2-O, 1/O] ans = 0 0 1 0 2 Inf %%%%%%%%%%%%%%%%% classdef SpecialZeros<double methods function obj=SpecialZeros(data) obj=obj(a)double(data); end function out=mrdivide(A,B) C=A./B; C( isnan(C)& A==0 )=0; out=C; end function out=rdivide(A,B) C=double(A)./double(B); C( isnan(C)& A==0 )=0; out=C; end end end
|
Pages: 1 Prev: Problem with third-level-choosers Next: interpreting data |