MATLAB: How to have the first value of the for loop to be zero.

for loop

If you can visualize a x vs T graph. Where x = 0:0.1:1; so 11 values starting from 0, going to 1 with an increment of 0.1
For all the value to x, I want to find the T values.
I know when x = 0, T = 0
when x = 0.5, T = 100
when x = 1, T = 0
It is basically a triangular graph where I'm trying to flood the values of T corresponding to each x.
I wrote this code. It works but I'm getting T = [20;40;60;80;100;80;60;40;20;0;-20] instead of T = [0;20;40;60;80;100;80;60;40;20;0].
How to fix this? Thanks in advance
clear all; close all; clc;
T = zeros(11,1);
x = 0:0.1:0.5;
for i = 1:length(x)
T(i) = 20*i;
end
y = 0.6:0.1:1;
for j = length(x):length(x)+length(y)
T(j) = ((-20)*j) + 200;
end

Best Answer

Replace
T(i)=20*i
T(j)=((-20)*j) + 200;
with
T(i)=20*(i-1)
T(j)=((-20)*(j-1)) + 200;
respectively.