|
|
How defining discontinuous function
I 'd like know how I can define a discontinuous function (such as f(x)=5 if x>5, f(x)=6x if x<5) and how I can evaluate it in a interval (such as [0 6]).
|
|
0
|
|
|
|
Reply
|
Stefanos
|
9/19/2010 8:06:03 PM |
|
On 19/09/10 3:06 PM, Stefanos Teliso wrote:
> I 'd like know how I can define a discontinuous function (such as f(x)=5
> if x>5, f(x)=6x if x<5) and how I can evaluate it in a interval (such as
> [0 6]).
function y = f(x)
y = nan(size(x));
y(x>5) = 5;
y(x < 5) = 6 * x(x < 5);
end
Note: using zeros instead of nan is more efficient, but using nan has
the advantage of making clear the problem you face when x is exactly 5.
If you do not mind using 0 for the undefined values, you could also use
f = @(x) (x>5) .* 5 + (x<5) .* 6 .* x;
This form can be used for all cases in which the formulas are
well-behaved at all points (i.e., not nan and not infinite) including
the points the sub-formulae are not intended to be applied to.
Note: if you intend to optimize or integrate over this function, then
you have to be very careful about how you do that. Most of the
optimizers assume continuous first derivatives at the very least.
|
|
0
|
|
|
|
Reply
|
Walter
|
9/19/2010 8:15:10 PM
|
|
|
1 Replies
599 Views
(page loaded in 0.022 seconds)
Similiar Articles: Optimization of a discontinuous function - comp.soft-sys.matlab ...How defining discontinuous function - comp.soft-sys.matlab ... Question for maximum ... it be easier now to define its most probable distribution? -0 ... what is the difference between db1, db2,db3,... in wavelet ...How defining discontinuous function - comp.soft-sys.matlab ... what is the difference between db1, db2,db3,... in wavelet ... How defining discontinuous function - comp ... Copula Estimation - One Step Maximum Likelihood - comp.soft-sys ...How defining discontinuous function - comp.soft-sys.matlab ... Question for maximum likelihood estimation in matlab - comp.soft ... Would it be easier now to ... how to score in phreg using time varying covariates - comp.soft ...How defining discontinuous function - comp.soft-sys.matlab ... how to score in phreg using time varying covariates - comp.soft ... How defining discontinuous function ... difference between objective and fitness function(s)? - comp.ai ...Optimization of a discontinuous function - comp.soft-sys.matlab ... what is the difference between db1, db2,db3 ... Non-smooth problems – where the objective and/or ... rescaling for fmincon - comp.soft-sys.matlab... function m-file takes 1/variance as the input, but i define an anonymous function that ... Optimization of a discontinuous function - comp.soft-sys.matlab ... rescaling for ... Unit step function - comp.soft-sys.matlabunit pulse function - comp.soft-sys.matlab How can i define the unit pulse function in terms of the ... denoted by H (but sometimes u or θ), is a discontinuous function whose ... Question for maximum likelihood estimation in matlab - comp.soft ...Would it be easier now to define its most probable distribution? -0 ... Optimization of a discontinuous function - comp.soft-sys.matlab ... Question for maximum ... Undefined function or method 'atan2' for input arguments of type ...... itself encounters its discontinuous ... comp.soft-sys.matlab What is ... sys.matlab Undefined function or method 'Regula_Falsi' for input arguments of type 'inline'. ... What is ... How to compute phase of FFT signal in real world? - comp.dsp ...What is in praxis all the time. Try to change the ... aperture; and a non-integer period sinusoid in discontinuous ... I found that the windowing function do not play any (or ... Discontinuous Functions ..... - Worsley School OnLine... the ...A function is continuous if it has no breaks. On this page we'll first look at some common continuous functions, and then show you the discontinuous ones that you're ... Continuous function - Wikipedia, the free encyclopediaIn mathematics, a continuous function is a function for which, intuitively, "small" changes in the input result in "small" changes in the output. Otherwise, a ... 7/20/2012 2:32:55 PM
|
|
|
|
|
|
|
|
|