% Print specified Simulink models in a given directory
% Syntax print_models(specifier) where specifier can be any syntax used in dir command

function print_models(wild_card)

if isempty(findstr(wild_card,'mdl'))
    wild_card = [wild_card '.mdl'];
end

d = dir(wild_card); % Get all the files that match the wild-card

if isempty(d)
    disp('There are no Simulink models in the path indicated.')
    return
end

for i = 1:size(d,1)
    a = d(i).name;
    loc_dot = findstr(a,'.');
    file_name = a(1:loc_dot-1);% Remove file extension
    try
        open_system(file_name)
        PrintModel(file_name)
        close_system(file_name)
    catch
        disp(['Unable to print model --->' file_name])
    end
end