Plotting the summation of a Heaviside step function

So I have written a script where I want to plot the summation of a Heaviside function, which equals this i.e :
where are real positive parameters with and u as real variable.
In the script i wrote i took as and u as x as follows :
n=7
m=0:0.5:24;
ms=size(m);
x=-20:2.5:100;
xs=size(x);
S=0;
for i=1:25
s(i)=heaviside(x(i)-m(i));
S=S+s(i);
end
S
plot(x,S)
However, it plots a straight line of dots with jumps in between which kept me wondering if this is right or wrong.
In my initial idea, I wanted to represent this problem with a symbolic math toolbox but I got lost doing that too, I would appreciate it if anyone could give me a hint on how to write one ?.

回答(0 个)

类别

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by