I am trying to plot the following curve 
I have written the following:
n=...;
tau=...;
t0=0;
tend=...;
t = linspace(t0,tend);
x = zeros(length(t));
for i=1:n
for j=1:length(t)
if ((i-1)*tau <= t(j)) && (t(j) <= i*tau)
A = zeros(i);
for k=1:i
A(k) = (-1)^k*((t(j)-(k-1)*tau)^k)/factorial(k);
end
x(j) = 1 + sum(A);
end
end
end
plot(t,x)
Of course with the values of n, tau and tend filled in depending on what I need it to be. This is where the problem arrises though as the code does not work for any value of n>1.
Any help would be greatly appreciated
0 Comments
Sign in to comment.