'My for loop won't output anything (Matlab)

I'm trying to get this for loop to work on Matlab so I can plot these three histograms. I'm guessing it won't output because it says that my variables such as a_M_S1 keep changing size on every loop iteration, so the process is essentially inefficient. Any help? Below is the code.

I'm basically trying to generate 500 samples of 100 readings so I can then plot a histogram using estimated parameter values.

clear
clc

% Importing Data

%a = 0.9575
for m=1:500
    seed=m;
    rng(seed);
    syms x
    F=((1/atanh(0.9575))*((0.9575^(2*x-1))/(2*x-1)));
    
   for n=1:100
    data_1(n)=ceil(vpasolve(F==rand(1)));
   end     
    Data_1(m,:)=data_1;
end
        
clear
clc

Data_1=[49     1     3    17    13     3     5    51     7     1
     9     3    67     1     3     1     1     1     1    99
     5    13    21    17    41     1     1     9    23     1
     1     5     1     1    41     1    13     1     5    27
     5    37    99     1     1    33     1     1     9     1
     1     3    47    11     7     1     1    41    21    27
     5     1     1    11    45     7     3     5     1    17
    13     5     3     3     1    99     1    59     1    13
     3     5     1    35     1     1     1     1     5    19
     5     1     1     1    79     3     1     1     1     1
    31     3     1     1     1    21    69    39     1    29
     3     3     1     1     5     1     3     1     1    15
     1     1     9     1     7     1     1     1     1    11
    27     9     1     3    39     5     1     5     7     1
     1     1     7     5     1     1     3     1     3    23
     5     1    21     1     1     7     1    17     1     3
    11    11     5     1     9     1     1     1     1    37
    33     1     9     7     1     1    31    27     1     1
     5     5     1    17     3    31     1    45    37     1
     1     1    19    47     9     7     5     1     9     1
    11     1    61     5    29     1    95     1     1     1
    13    19     1     1    13     1    23     7    73     1
     1     1    11     1     5     1     3     1     7     1
    15     1     9    53     3     7     3    21     7     3
     1     7     1     1    23     7     5     1     3     1
     1     7     1     3     1     1     1     7     3     5
     1     1     1    43     7     3     1     1    21     5
     1    39     1     5    13     3     1     5     1     3
     1    11     1     1    29    17    25     1     9     1
    17     9    13    11     1     5    29     3     3     1
    65     5    63     1     1     3     5     1     7     1
    21     3     7     1     1     1    27    11    15     3
     1     1     1     1    21     1     5     3     1    11
     5     1     3     7     1     5    43     5     7    75
    29     7    83     1     3     5    15     1     1     3
     1     1     9     1    13     1    17    23     1     5
    99     1     1     1     5     7     9     3     7     1
     1    11     1    11    21     1     5     9     5     1
    33    49     3     9    15     1     1     5     1     1
     1    17     1     1     1     1    13     1     1     9
     5    13     1     1     5     3     1     1    67     1
     5     1     1     1     7    27     1    21    47     1
     1     1     1    21     3    17     1     5     5     1
     1     1    17    29    99     1     9     1     5    15
    17     5     1    13     1     1     1     1     1    21
     1    21     1     1     1    11     9    35    31    15
    99    15     1     1     9     3     1    21     1     1
     1     1     9    33     1     1    31     9    29    47
    41    99     1     7    17     5     9     3     3    13
     1    29     9     5    11     1     1     7    37    15];
 
 Data_2=[1     1     3     3     5     7     1     3     1     1
     1     1     1     1     1     1     1     1     1    13
     5     1     5     1     1     1     1     3     1     1
     1     1     3     1     1     1     1     3     1     1
     1     1    13     5     1     3     1     1     5     1
     3     3     1     7     3     5     3     1     3     1
     1     1     1     1     1     3     3     5     1     1
     1     1     1     9     1     1     1     1     5     1
     1     1     1     1     1    11     7     1     5     1
    17     1     1     7     3     7     3     5     5     1];
 
for o=1:500
    syms a
    %Method of Moments (MM)
    mean_S1 = mean(transpose(Data_1(o,:)));
    a_MM_S1(o) = vpa(vpasolve((a)/((atanh(a))*(1-a.^2)) == mean_S1,a),4);
    
    mean_S2 = mean(transpose(Data_2(o,:)));
    a_MM_S2(o) = vpa(vpasolve((a)/((atanh(a))*(1-a.^2)) == mean_S2,a),4);
    
    %Using Lower Quantile (OS)
    lower_S1 = floor(quantile(Data_1(o,:),0.25));
    a_LQ_S1(o) = vpa(vpasolve((a)/(atanh(a)) == 0.25,a),4);
    
    lower_S2 = floor(quantile(Data_2(o,:),0.25));
    a_LQ_S2(o) = vpa(vpasolve((a)/(atanh(a)) == 0.25,a),4);
    
    %Using Median (OSM)
    median_S1 = floor(quantile(Data_1(o,:),0.5));
    a_M_S1(o) = vpa(vpasolve((a)/(atanh(a)) == 0.5,a),4);
    
    median_S2 = floor(quantile(Data_2(o,:),0.5));
    a_M_S2(o) = vpa(vpasolve((a)/(atanh(a)) == 0.5,a),4);  
  
end

a_MM_S1=transpose(a_MM_S1);
a_LQ_S1=transpose(a_LQ_S1);
a_M_S1=transpose(a_M_S1);
a_MM_S2=transpose(a_MM_S2);
a_LQ_S2=transpose(a_LQ_S2);
a_M_S2=transpose(a_M_S2);

figure(1)
histogram([double(a_MM_S1),double(a_MM_S2)],20),title('Method of Moments')
figure(2)
histogram([double(a_LQ_S1),double(a_LQ_S2)],20),title('Using Lower Quartile as Estimator')
figure(3)
histogram([double(a_M_S1),double(a_M_S2)],20),title('Using Median as Estimator')


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source