You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: countAllFolders.m
    path of file: ./repos/trajectory-based-ship-classification/Code/0.others/countFiles
    
    the code of the file until where you have to start completion: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
    
function [] = countAllFoldersRecursive(folder, fileWrite)

allFiles = dir(strcat(folder, "/*.*"));
folders = allFiles([allFiles.isdir]); % getting all folders in the folder
folders(1:2) = []; % Deleting . and .. folders


for k=1:length(folders)
    thisPath = strcat(folder, "/", folders(k).name);
    allFiles2 = dir(strcat(thisPath, "/*.*"));
    allFiles2(1:2) = []; % Deleting . and .. folders
    if sum([allFiles2(:).isdir]) > 0 % If it still have folders to analyze, keep on the recursive searching
        %disp("Not a final folder");
        countAllFoldersRecursive(thisPath, fileWrite);
        
    else                            % If its a final folder, all its files are analyzed, writing the results in a single line
        [numFiles, numEntries, numManeuverType, numShipType] = countFolder(thisPath);
        disp("Soy carpeta: "+thisPath);
        fid = fopen(fileWrite, 'a');
        fprintf(fid, strcat(num2str(numFiles), '; ', num2str(numEntries), '; '));
        for i=1:length(numShipType)
            fprintf(fid, strcat(num2str(numShipType(i)), '; '));
        end