Programming With MATLAB - MATLAB & Simulink

Transcription

Programming with MATLABPaolo FabbriSenior Engineer 2014 The MathWorks, Inc.1

MATLAB Application Development LandscapePrototypingProgrammingDeployment2

MATLAB Application Development LandscapePrototypingProgrammingDeployment3

MATLAB Application Development LandscapePrototypingProgrammingDeployment4

Today FocusObject-Oriented ProgrammingUnit Test FrameworkPrototypingProgrammingDeploymentSource Control IntegrationProgramming Interfaces5

What is a program?6

What is a program?Codex 12while (x 100)x x 1if (x 23)disp('Hello')endendx 12while (x 100)x x 1if (x 23)disp('Hello')endendDataAssignmentLooping TestIncrementTest to ActTake ActionEndEndOperations7

Range of Programming ass(methods)functionscriptcommand lineOperations8

Classes and ObjectsPaoloPropertiesPeoplePropertiesMethods FirstName LastName BirthDate Address Contacts getFullName getAge FirstName LastName BirthDate Address ContactsMethods PaoloFabbri. getFullName getAgeDavideProperties FirstName LastName BirthDate Address ContactsMethods DavideFerraro. getFullName getAge9

Object-Oriented Programming BasicsPeoplepropertiesencapsulate object datamethodsimplement the object behaviorPropertiesMethods FirstName LastName BirthDate Address Contacts getFullName getAgeevents and listenersimplement objects communicationinerithanceallows composition and reusabilityEmployeePropertiesMethods Salary Group Manager showInOrgChart10

Object-Oriented Programming with MATLABpropertiesencapsulate object datamethodsimplement the object behaviorevents and listenersimplement objects communicationinerithanceallows composition and reusability11

Case Study: Team Resources AssignmentResource ManagerSubmit TaskClientsResponseResources12

MATLAB Unit Test Framework13

Application Development ProcessRequirementsResearch & DesignDesignExplore and discoverGain insight into problemTestElaborateImplementationDesktop or WebEmbedded software andDeploymentdigital electronics.dll.exeC, C Test & VerificationEvaluate options, trade-offsC, C VHDL, Verilog14

xUnit PatternsMany testing Best Practices are emergingbuilt around xUnit Consistent nomenclature Consistent architecture Platform for robust testing methodologies Setup/Teardown capabilities15

MATLAB Unit Test FrameworkWrite, run and analyze tests for MATLAB programsWrite in function form or xUnit-style class formRun tests individually or grouped into a test suiteAnalyze values using qualification functionsSetup and teardown to pretest and restore a stateAdvanced testing capabilities16

Types of QualificationsTypeActionVerifyFail & Continue ExecutionAssertFail & Halt Current Test, Continue to NextFatal assertFail & Halt Framework ExecutionAssumeFilter Current Test17

Source Control Integration18

Source Control Integration in MATLABStay inside MATLAB for development workflowGIT and Subversion Integration in Current FolderIntegrated with tools designed for MathWorksfile types (i.e. compare and merge)19

Programming Interfaces20

Calling MATLAB from Other LanguagesEngine interface C/C Fortran Python C/C FortranPythonAutomation server COM .NET.NETCOMCOM21

Calling Other Languages from MATLABMATLAB C and Fortran API mex mycode.cC/C MATLAB interface to C shared library loadlibrary(‘foo', ‘foo.h')FortranMATLAB COM client support actxserver('Excel.Application')PythonMATLAB .NET interface NET.addAssembly('System.Speech').NETMATLAB Java interface java.lang.String('boo')COMMATLAB Python interface py.textwrap.wrap('Text');Java22

Target-Specific ImplementationandLarge Scale Distribution23

MATLAB Application Development LandscapePrototypingProgrammingDeployment24

MATLAB Application Development LandscapePrototypingProgrammingDeployment25

Thank You!26

Object-Oriented Programming with MATLAB properties encapsulate object data methods implement the object behavior eventsand listeners implement objects communication inerithance allows composition and reusability. 12 Case Study: Team Re