MATLAB: How to replace a string of numbers with more numbers using for and if statements

helpMATLAB

Here is my code so far. I'm trying to make it so that if the number is "1" in the string, it replaces it with five zeros. If the number is "2" in the string it replaces that with 5 ones, and if the number is "3" in the string, it replaces it with 5 twos and make that all a different string of numbers called d. The end should look like this: d = [0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,2,2,2,2,2]. I really need help, I am awful with matlab.
if true
t = [1,2,1,2,1,3];
% For Loop
for n = 1:length(t)
if t(n) == 1
d(n) = 0,0,0,0,0;
elseif t(n) == 2
d(n) = 1,1,1,1,1;
else t(n) == 3
d = 2,2,2,2,2;
end
end
end

Best Answer

t = string([1,2,1,2,1,3]);
d=cell(1,numel(t)); %pre-allocation
for i = 1:numel(t)
if t(i)=='1'
d{i}=[ones(1,5)*0];
elseif t(i)=='2'
d{i}=[ones(1,5)*1];
elseif t(i)=='3'
d{i}=[ones(1,5)*2];
end
end
d = horzcat(d{:})
command window:
>> COMMUNITY
d =
Columns 1 through 13
0 0 0 0 0 1 1 1 1 1 0 0 0
Columns 14 through 26
0 0 1 1 1 1 1 0 0 0 0 0 2
Columns 27 through 30
2 2 2 2
>>