2 Solve the following using a forend loop to create three ve
2. Solve the following using a for-end loop to create three vectors
i T contains the integers between 1 and 50
ii. Y contains elements where each element is Yn=1-e^(-T/10)
iii. Vector dY contains the values of the change in y, that is dYn=Yn+1-Yn. Note that since each dY takes two Y to calculate, there will be one less dY (49).
iv. Display T ,Y and dY in a table
v. Plot Y(vertical) against T(horizontal) vi. Plot dY(vertical against T(horizontal)
Solution
T = zeros(50, 1);
Y = zeros(50, 1);
dY = zeros(50, 1);
for i=1:1:50
T(i) = i;
Y(i) = 1-exp(-1.0*i/10);
if i>1
dY(i-1) = Y(i) - Y(i-1);
end
end
Table = table(T, Y, dY);
disp(Table);
plot(T, Y);
plot(T, dY);
