From: Matt J on 30 Jul 2010 10:39 "Nils Tobias " <nils.kraemer(a)uni-ulm.de> wrote in message <i2ubbm$olu$1(a)fred.mathworks.com>... > Thanks Stefan, > > I thought there might be way to redefine this property. Anyway in my case it somehow makes sense because I could define my equation also without the division... which I probably should do. > > But for now I just calculate it like you suggested with a simple M-file called wrongdivision.m ============= 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 It will let you do things like this >> O=SpecialZeros(0); >> 1/O ans = Inf >> 0/O ans = 0 >> O/1 ans = 0 %%%%%%%%%%%% function obj=SpecialZeros(A) obj=MatrixObj; obj.Params=A; obj.Ops.rdivide=(a)wrongdivision; obj.Ops.mrdivide=(a)wrongdivision; function out=wrongdivision(A,B) if isa(A,'MatrixObj'), A=A.Params; end if isa(B,'MatrixObj'), B=B.Params; end C=A./B; C( isnan(C)& A==0 )=0; %out=SpecialZeros(C); out=C; end end
|
Pages: 1 Prev: Load Listbox from Array Next: Problem with third-level-choosers |