get_F_semiintrusive input size

get_F_semiintrusive input size

function input_dim = get_F_semi_input_dim(F_semi,n)

try

    v = zeros(n,1);
    for j = 1:numel(F_semi)
        fnl_j = F_semi{j};

        input = cell(j+1,1);
        for i = 1:(j+1)
            input{i} = v;
        end
        if ~isempty(fnl_j)
            fnl_j(input)
        end
    end

    input_dim = n;

catch

    try
        v = zeros(N,1);

        for j = 1:numel(F_semi)
            fnl_j = F_semi{j};

            input = cell(j+1,1);
            for i = 1:(j+1)
                input{i} = v;
            end
            if ~isempty(fnl_j)
                fnl_j(input)
            end

        end

        input_dim = N;
    catch

        error('Please check input dimension for the nonlinearity function handle')
    end
end