'how to create a 3D matrix in a loop , where in each loop the matrix size might change?

i wrote this code where i have array of matrics(alpha_mom_DR_data_array), and in this array , there are matrics in different sizes , for each one i want to calculate something and then save the results in a 3D matrix "curr_alpha_DR_PLV_struct" , so the 3D matrix size in each loop changes , how can i do this? because if i did like bellow i get an error "Unrecognized function or variable 'curr_alpha_DR_PLV_struct'." thank you .

num_matrics_struct=11;
k=0;
curr_trial=0;
Total=0;
trial_length = 250;
for curr_mat_idx=1:num_matrics_struct
    [rows,col]=size(alpha_mom_DR_data_array(curr_mat_idx)) 
    num_trials=floor(col/trial_length); 
    for curr_trial=1:num_trials  
        for mother_ch=1:rows
            for child_ch=1:rows
                for k=(curr_trial-1)*trial_length+1:trial_length*l
                    Total=Total+exp(1i*(alpha_mom_DR_data_array(curr_mat_idx).matrix.a(mother_ch,k)-alpha_child_DR_data_array(curr_mat_idx).matrix.a(child_ch,k)));
                end
                Total=abs(Total);
                Total=Total/trial_length;
                curr_alpha_DR_PLV_struct(mother_ch,child_ch,curr_trial,curr_mat_idx)=Total;
                Total=0;
            end
        end
    end
    PLV_Array_Alpha_DR_mean(curr_mat_idx)=calculate_trials_mean(curr_alpha_DR_PLV_struct,num_trials);
end


Sources

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

Source: Stack Overflow

Solution Source