"Animesh Pandey" wrote in message <ihcj3t$9fn$1@fred.mathworks.com>...
> t = 10:0.1:10; % Unit Step Function
> y(t>=0) = 1;
> y(t<0) = 0;
> plot(t,y)
>
> %%
>
> t = 2 :0.001: 2; % Unit Impulse.......
> y(t==0) = 1;
> y(t~=0) = 0;
> plot(t,y)
>
> %%
>
> t = 2 : 0.001 : 2; %Ramp Function
> y(t>=0) = t;
> y(t<0) = 0;
> plot(t,y)
> %%
>
> For the Unit Step I am getting an error
> ??? Error using ==> plot
> Vectors must be the same lengths.
>
> For the Impulse func. if I change 't = 2 : 0.001 : 2 ' .... to something other like
> t = 10 :0.1 :10....
>
> Please help me removing those errors !!!!
>
> For the Ramp....
> ??? In an assignment A(:) = B, the number of elements in A and B
> must be the same.
the problem I think you have is that y was defined before and you didn't clear it, so it has a different length from t, your code only changes part of y, do this before assign values to y that way:
clear y %or clear or clear all, y=0 will also work, you must have length(y)<length(t)
%your code remains the same
t = 10:0.1:10; % Unit Step Function
y(t>=0) = 1;
y(t<0) = 0;
plot(t,y)
