MATLAB: Problem with taking Differentiate from variable with counter !

variable diff counter

Best Answer

Well, the approach would be as follows:
n=30;
x=sym(zeros(1,n));%preallocation
syms t
for i=1:n
x(i)=str2sym(sprintf('x%d(t)',i));
end
Now, you can easily take derivative of x as
diff(x,t)
and observe the result you want.