From: saurabh gupta on 16 Feb 2010 22:40 "us " <us(a)neurol.unizh.ch> wrote in message <hle26c$ogs$1(a)fred.mathworks.com>... > "saurabh gupta" <saurabh(a)isu.iisc.ernet.in> wrote in message <hle1fq$9k8$1(a)fred.mathworks.com>... > > i hav a function handler > > fu = @(x,y)f(x,y) > > > > x and y are symbolic real > > because of calculations in the function f, sometimes y variable is becoming zero, > > > > now when i m doing feval(fu,X,Y)(where X and Y are constant values) it is showing excess arguments error... because there is no y in the function. > > > > Is there any technique by which i can put the if condition for the arguments st > > > > if (arguments has x) > > feval (fu,X) > > > > OR > > > > if (arguments has y) > > feval (fu,Y) > > > > OR > > > > if (arguments has x and y) > > feval (fu,X,Y) > > > > thanking you... > > just a note: > > % - you do NOT need to call FEVAL... > % - simply use > > r=fu(x,y); > > % also, you could(!, see below) use this approach for variable input args... > > fu=@(varargin) f(varargin{:}); > % or > fu=@f; > % then > fu(x,y,z,...); > > % however, an anonymous function will not allow you to make decisions > % upon the number in input args... > % hence, in your case, this would be left to F(...) > > us but if x is missing in the function how will i make sure that the second argument value it is taking for y... coz at that time only value for one variable is needed... and will it not take the first argument for y which is actually the value of x
From: saurabh gupta on 16 Feb 2010 22:44 "us " <us(a)neurol.unizh.ch> wrote in message <hle26c$ogs$1(a)fred.mathworks.com>... > "saurabh gupta" <saurabh(a)isu.iisc.ernet.in> wrote in message <hle1fq$9k8$1(a)fred.mathworks.com>... > > i hav a function handler > > fu = @(x,y)f(x,y) > > > > x and y are symbolic real > > because of calculations in the function f, sometimes y variable is becoming zero, > > > > now when i m doing feval(fu,X,Y)(where X and Y are constant values) it is showing excess arguments error... because there is no y in the function. > > > > Is there any technique by which i can put the if condition for the arguments st > > > > if (arguments has x) > > feval (fu,X) > > > > OR > > > > if (arguments has y) > > feval (fu,Y) > > > > OR > > > > if (arguments has x and y) > > feval (fu,X,Y) > > > > thanking you... > > just a note: > > % - you do NOT need to call FEVAL... > % - simply use > > r=fu(x,y); > > % also, you could(!, see below) use this approach for variable input args... > > fu=@(varargin) f(varargin{:}); > % or > fu=@f; > % then > fu(x,y,z,...); > > % however, an anonymous function will not allow you to make decisions > % upon the number in input args... > % hence, in your case, this would be left to F(...) > > us but if x is missing in the function how will i make sure that the second argument value it is taking for y... coz at that time only value for one variable is needed... and will it not take the first argument for y which is actually the value of x
|
Pages: 1 Prev: Plot Gaussian dataset in 3D Next: passing objects to gui |