www.gusucode.com > rtwdemos 工具箱matlab源码程序 > rtwdemos/rtwdemo_lct_makedemos.m

    function rtwdemo_lct_makedemos(isPublishingArch)
%RTWDEMO_LCT_MAKEDEMOS make LCT example S-Functions as part of mex phase

%   Copyright 2005-2015 The MathWorks, Inc.

origDir = pwd;

EXT=mexext;
addpath(origDir);

tempDir = tempname;
mkdir(tempDir);
cd(tempDir);
obj = onCleanup(@() doCleanup(origDir, tempDir));

try
    % Make sure the building script runs in the base workspace
    % to avoid any resolution issue with Simulink Data objects
    evalin('base', 'rtwdemo_lct_builddemos;');

    disp ('### Copy and delete contents of tempdir')
    copyfile(['rtwdemo_sfun*.', EXT],origDir);
    copyfile('rtwmakecfg.m',origDir);
    % if it is the publishing platform, copy C, CPP and TLC files.
    if isPublishingArch
        copyfile('rtwdemo_sfun*.c',origDir);
        copyfile('rtwdemo_sfun*.cpp',origDir);
        copyfile('rtwdemo_sfun*.tlc',origDir);
    end
    evalin('base', 'clear mex');
    delete([tempDir filesep '*']);
catch Me
    disp(Me);
    throw(Me)
end

%% ----------------------------------------------------------------------------
function doCleanup(origDir, tempDir)

cd(origDir);
rmdir(tempDir, 's');