# MATLAB: Define a name of the variable using the value of other variable

MATLAB

Suppise I have data
Month Day Visitors----------------------------January 1 100January 7 50February 1 400February 3 200
I want to create a variable that is a proxy for months such as
Month Day Visitors proxy_January proxy_February------------------------------------------------January 1 100      1             0January 7 50       1             0February 1 400     0             1February 3 200     0             1
One way to do this is to define variables one by one for each month.
But I would like to know how I can let Matlab do this automatically.
set_of_month=unique(T.Month)
for i=1:length(set_of_states)    for j=1:height(T)        if T.Month(j)=set_of_month(i)            T.set_of_month(i)=1        else            T.set_of_month(i)=0        end    endend
Month={'January'; 'January'; 'February'; 'February'};set_of_month=unique(Month);% Add a matrix of zeros to host the dummy variablesdum=zeros(length(Month),length(set_of_month));T=[table(Month) array2table(dum)];% Add the labelsT.Properties.VariableNames(2:end)=set_of_month;% Add the ones in the corresponding position for i=1:length(set_of_month)    for j=1:height(T)        if strcmp(T.Month{j},set_of_month{i})            T{j,i+1}=1;        end    end end  disp(T)%       Month        February    January%     ____________    ________    _______% %     {'January' }       0           1   %     {'January' }       0           1   %     {'February'}       1           0   %     {'February'}       1           0