Using MATLAB (779505), страница 35
Текст из файла (страница 35)
. . . . . . . . . . 9-3Viewing or Selecting the Source Control System . . . 9-4Function Alternative for Viewing the SCS . . . . . . . . 9-5Setting Up the Source Control System . . . . . . . . 9-6For SourceSafe Only – Mirroring MATLAB Hierarchy . .
. 9-6For ClearCase on UNIX Only – Set a View andCheck Out a Directory . . . . . . . . . . . . . . 9-6Checking Files into the Source Control System . . . . 9-7Function Alternative for Checking In Files . . . . . . . . 9-8Checking Files Out of the SCS . . . . . . . . . . . . 9-9Function Alternative for Checking Out Files . . . . . . . 9-10Undoing the Check-Out . . . . .
. . . . . . . . . . . 9-109Interfacing with Source Control SystemsIf you use a source control system (SCS) to manage your files, you can checkM-files and Simulink and Stateflow files into and out of the source controlsystem from within MATLAB, Simulink, and Stateflow.MATLAB, Simulink, and Stateflow do not perform source control functions,but only provide an interface to your own source control system. This means,for example, that you can open a file in the MATLAB Editor and modify itwithout checking it out. However, the file will remain read-only so that youcannot accidentally overwrite the source control version of the file.Four popular source control systems are supported, as well as a custom option:• ClearCase from Rational Software• PVCS from Merant• RCS• Visual SourceSafe from Microsoft• Custom option – Allows you to build your own interface if you use a differentsource control system9-2Process of Interfacing to an SCSProcess of Interfacing to an SCSYou can interface to your source control system by using menus if you prefer agraphical user interface, or by using functions if you prefer to use theCommand Window.
There are some options you can perform using thefunctions that are not available with the menus – these are noted in theinstructions.Create M-files, Simulink files, or Stateflow files as you normally would andsave the files. Then follow these steps to use MATLAB, Simulink, or Stateflowto interface with your source control system.StepsInstructions1 Select the source control system touse.See “Viewing or Selecting theSource Control System” onpage 9-4.2 Set up your source control systemto correctly include the files.
Thisis only required for some sourcecontrol systems.“For SourceSafe Only – MirroringMATLAB Hierarchy” on page 9-63 Check the files into the sourcecontrol system. Note that for somesource control systems, you mustcheck out the files before you cancheck them in.“Checking Files into the SourceControl System” on page 9-74 Next time you want to modify thefiles, open them in the MATLABEditor, Simulink, or Stateflow, andcheck them out.“Checking Files Out of the SCS”on page 9-95 Undo a check-out if you want thefiles to remain checked in, withoutany of the changes you made sinceyou checked them out.“Undoing the Check-Out” onpage 9-10“For ClearCase on UNIX Only –Set a View and Check Out aDirectory” on page 9-69-39Interfacing with Source Control SystemsViewing or Selecting the Source Control SystemSpecify the source control system for MATLAB to interface with:1 From the MATLAB desktop, select Preferences from the File menu.
Youcan also select this from the Simulink or Stateflow model or librarywindows.The Preferences dialog box opens.2 Click the + for General and then select Source Control.The currently selected system is shown. The default selection is None.3 Select the system you want to use from the Source control system list.9-4Viewing or Selecting the Source Control System4 For Visual SourceSafe only, supply your Username, Password, and theDatabase.- Password is not required if SourceSafe does not require it.- Database is the full path for the srcsafe.ini file associated with theSourceSafe database you want to use. For example,D:\Applications\Microsoft SourceSafe\srcsafe.ini.5 Click OK.Function Alternative for Viewing the SCSTo view the currently selected system, type cmopts in the Command Window.MATLAB displays the current source control system.9-59Interfacing with Source Control SystemsSetting Up the Source Control SystemFor ClearCase on UNIX and for SourceSafe, set up your source control systemas described here.For SourceSafe Only – Mirroring MATLAB HierarchyIf you use Visual SourceSafe, you must set up a project hierarchy in SourceSafethat mirrors the hierarchy of your MATLAB, Simulink, and Stateflow files.
Forexample, if you want to use the MATLAB Editor to interface to SourceSafe forthe files in D:\matlabr12\mymfiles, configure a SourceSafe project as$:\matlabr12\mymfiles.In addition to setting up the hierarchy, you must supply your user name,password, and database in MATLAB general preferences. See “Viewing orSelecting the Source Control System” on page 9-4 for instructions.For ClearCase on UNIX Only – Set a View and CheckOut a DirectoryIf you use ClearCase on a UNIX platform, do the following using ClearCase:1 Set a view.2 Check out the directory in which you want to save files, check files into, orcheck files out of.You can now use the MATLAB, Simulink, or Stateflow interfaces to ClearCaseto check files into and out of the directory you checked out in step 2.9-6Checking Files into the Source Control SystemChecking Files into the Source Control SystemAfter creating or editing a file in the MATLAB Editor, Simulink, or Stateflow,save it, and then check in the file by following these steps:1 From the MATLAB Editor, select File -> Source Control -> Check In.
Youcan also select this from the Simulink or Stateflow model or librarywindows.The Check in dialog box opens.2 If you want to check in the file but keep it checked out so you can continuemaking changes, select Keep checked out.3 If you have comments, type them in the Comments area.Your comments will be submitted whether or not you select Keep checkedout, y.4 Click OK.The file is checked into the source control system. If you did not save the filebefore checking it in, it is automatically saved when it is checked in.If you did not keep the file checked out and you keep the file open, note that itis a read-only version.9-79Interfacing with Source Control SystemsFunction Alternative for Checking In FilesUse checkin to check files into the source control system. The files can be openor closed when you use checkin.
The checkin function has this form.checkin({'file1',...'filen'},'comments','string','option',...'value')For file, use the complete path. You must supply the comments argument anda comments string with checkin.Use the option argument to:• Check in a file and keep it checked out – set the lock option to on.• Check in a file even though it has not changed since the previous check in –set the force option to on.The comments argument, and the lock and force options apply to all fileschecked in.After checking in the file, if you did not keep it checked out and have it open,note that it is a read-only version.Example – Check in a File with CommentsTo check in the file clock.m with a comment Adjustment for Y2K, typecheckin('\matlabr12\mymfiles\clock.m','comments','Adjustment ...for Y2K')For other examples, see the reference page for checkin.9-8Checking Files Out of the SCSChecking Files Out of the SCSTo check files out of the source control system using MATLAB, follow thesesteps:1 Open the M-file, Simulink file, or Stateflow file you want to check out.The file opens and the title bar indicates it is read-only.2 From the MATLAB Editor, select File -> Source Control -> Check Out.
Youcan also select this from the Simulink or Stateflow model or librarywindows.The Check-Out dialog box opens.3 To check out the version that was most recently checked in, select Latest. Tocheck out a specific version of the file, select Specific and type the versionnumber in the fieldWhen you check out the latest version, you can use the Lock option. Toprevent others from checking out the file while you have it checked out,select Lock.
To check out a read-only version of the file, uncheck Lock.4 Click OK.The file is checked out from the source control system and is available to youfor editing.9-99Interfacing with Source Control SystemsFunction Alternative for Checking Out FilesUse checkout to check a file out of the source control system. You can check outmultiple files at once and specify check-out options.
The checkout function hasthis form.checkout({'file1',...'filen'},'option','value')For file, use the complete path.Use the option argument to:• Check out a read-only version of the file – set the lock option to off.• Check out the file even if you already have it checked out – set the forceoption to on.• Check out a specific revision of the file – use the revision option, and assignthe revision number to the value argument.The options apply to all files checked out. The file can be open or closed whenyou use checkout.Example – Check out a Specific Revision of a FileTo check out the 1.1 revision of the file clock.m, typecheckout('\matlab\mymfiles\clock.m', 'revision', '1.1')For other examples, see the reference page for checkout.Undoing the Check-OutYou can undo the check-out for a file.
The files remain checked in, without anyof the changes you made since you checked them out. If you want to keep a localcopy of your changes, use the Save As item from the File menu.From the MATLAB Editor, select File -> Source Control -> Undo Check Out.You can also select this from the Simulink or Stateflow model or librarywindows.9-10Checking Files Out of the SCSFunction Alternative for Undoing a Check-OutThe undocheckout function has this form.undocheckout({'file1',...'filen'})Use the complete path for file.Example – Undo the Check-Out for Two Files.
To undo the check-out for the filesclock.m and calendar.m, typeundocheckout({'\matlab\mymfiles\clock.m','\matlab\mymfiles\calendar.m'})9-119Interfacing with Source Control Systems9-1210Using NotebookNotebook Basics . . . . . . . . . . .Creating an M-Book . . . . . . . . . .Entering MATLAB Commands in an M-BookProtecting the Integrity of Your Workspace .Ensuring Data Consistency . . . . . .
.. . .. . .. .. . .. . ................. 10-3. 10-3. 10-6. 10-6. 10-7Defining MATLAB Commands as Input CellsDefining Cell Groups . . . . . . . . . . . .Defining Autoinit Input Cells . . . . . . . .Defining Calc Zones . . . . . . . . . . . .Converting an Input Cell to Text . . . . . . ...................... 10-8. 10-810-1010-1010-11Evaluating MATLAB Commands. . . . .Evaluating Cell Groups . . . .
















