Prev: Video Background Subtraction using GMM
Next: fminsearch
From: Mario Fatafehi on 13 Mar 2010 09:31 I have x(t) = t-1 for -1=<t<=1 and x(t) =0 otherwise. I thought of using a function but I think it may not be right? Any ideas? t=-2:0.1:2; if -1=< t <=1 x=t-1 plot(t,x) else x=0 plot(t,x) end
From: John D'Errico on 13 Mar 2010 12:49 "Mario Fatafehi" <coruba9(a)hotmail.com> wrote in message <hng7j9$j5j$1(a)fred.mathworks.com>... > I have x(t) = t-1 for -1=<t<=1 and x(t) =0 otherwise. I thought of using a function but I think it may not be right? Any ideas? > t=-2:0.1:2; > if -1=< t <=1 > x=t-1 > plot(t,x) > else > x=0 > plot(t,x) > end Several problems with a simple snippet of code. In fact, your problems are concentrated on one single line. You cannot use if to apply to an entire vector at one time. help if Worse, this is NOT the test that you think it is in MATLAB: -1=< t <=1 To achieve that, you need to do it as (-1=< t) & (t <=1) Regardless, if is inappropriate to use for a vector. Download piecewise_eval from the FEX: http://www.mathworks.com/matlabcentral/fileexchange/9394 HTH, John
|
Pages: 1 Prev: Video Background Subtraction using GMM Next: fminsearch |