MATLAB: Array indices must be positive integers or logical values Error

array indices errorMATLAB

I'm trying to execute this for loop and I keep coming up with same error. I don't understand why this is happening so if you could help at all it would be greatly appreciated.
for t= linspace(0,99)
C_1=x0;
C_2=x0_dot+(Wn*x0);
x(t)= (C_1 + (C_2*t))*exp(-Wn*t);
end

Best Answer

t= linspace(0,99);
for i = 1:numel(t)
C_1=x0;
C_2=x0_dot+(Wn*x0);
x(i)= (C_1 + (C_2*t(i)))*exp(-Wn*t(i));
end
plot(t,x)
if x0, x0_dot and Wn are scalars meaning a single number then you can do something like:
t = linspace(0,99);
C_1=x0;
C_2=x0_dot+(Wn*x0);
x = (C_1 + (C_2.*t)).*exp(-Wn.*t);
plot(t,x)