On Dec 23, 3:41 am, "Nasser M. Abbasi" <n...@12000.org> wrote:
> On 12/22/2010 3:36 PM, Hind wrote:
>
> > How to manually write the code for a matlab unit step function, by
> > user written function.
> > thanks
>
> You could aways use Matlab heaviside
>
> n = 10:10;
> y =heaviside(n);
> plot(n,y);
>
> or to make the plot more clear, do
>
> t = 1:0.001:1;
> y = heaviside(t);
> plot(t,y);
>
> or you could do:
>
> t = 1:0.001:1;
> y = ones( size(t) ) .* (t >= 0) ;
> plot(t,y);
>
> or you could also make a function y(t) which returns 1 if t>=0
> and use it. for example, for discrete:
>
> function t1()
> close all
> n = 10:10;
> y = mystep(n);
> plot(n,y);
> end
>
> function y=mystep(n)
> y=n>=0;
> end
>
> ps. note heaviside(t) = 1/2 at t=0, sometimes you might want
> step(0)=1, you decide which definition you want to use.
>
> Nasser
Thank you too much, but I need plot (heaviside(t)heaviside(ttd))
this function for step input pulse,
my programe:
t=0:0.001:1;
td=0.3;
y=heaviside(ttd);
plot(t,y)
but the problem the figure not complate, what I can do, please?
