Reputation: 15
I am trying to output this signal on MATLAB and everything looks fine except for the dirac part. It is supposed to go straight up to y=2 at t=10 but it carries on horizontal. How can I fix this?
t=linspace(0,11,1101);
%create more than 500 time-series values
vs=exp(-4*(t-1)).*heaviside(t-1)+0.5*heaviside(t-5)+2*dirac(t-10);
%Input signal array
t1=linspace(0,22,2201);
plot(t,vs)
xlabel('t')
ylabel('v_s(t)')
title('Input signal')
Upvotes: 0
Views: 38
Reputation: 6863
Your signal goes to Inf
at t=10
, as expected. This is why you cannot see it in the plot (if you zoom in you should see a missing data point).
You can set the Inf
value to a very high value (see the docs):
t=linspace(0,11,1101);
vs=exp(-4*(t-1)).*heaviside(t-1)+0.5*heaviside(t-5)+2*dirac(t-10);
vs(vs == Inf) = 100; % some high valueaxis limits
You can choose the value that it is visible as a sharp peak, but doesn't mess up your axis limits.
Upvotes: 2