MECH1004 - Slides - Section 16 Greyscale 6 To Page
MECH1004 - Slides - Section 16 Greyscale 6 To Page
MECH1004 - Slides - Section 16 Greyscale 6 To Page
COMPUTING
MECH1004
COMPUTING
It can be applied to a wide range of technical disciplines: DIGITAL SIGNAL PROCESSING CONTROL THEORY LINEAR ALGEBRA SIGNALS AND SYSTEMS NUMERICAL METHODS ADVANCED ENGINEERING MATHEMATICS
MECH1004
COMPUTING
MECH1004
COMPUTING
MATLABs principal features are: MATRIX COMPUTATION INTEGRATED GRAPHICS TOOLBOXES MATLAB is not a programming language, although it has its own programming facility within it. Rather, it is like a test-bench where you can play around with formulae and mathematical constructs, plot graphs and, yes, write programs if you need to. (MATLAB = MATrix LABoratory)
Having said that MATLAB is not a programming language, many people treat it as such because its programming facility can be made to be on a par with other high level languages. In normal use MATLAB programs are loaded and run within the MATLAB programming environment. They are then interpreted line by line, where each line of MATLAB source code is converted in turn to a binary instruction for the computers CPU to work on. This is in contrast to compiled languages like FORTRAN where all the lines of source code are converted into binary code, and optimised, within a ready-to-run .exe file (executable file).
MECH1004
COMPUTING
MECH1004
COMPUTING
Thus, a MATLAB program running within the MATLAB environment will not usually be as fast as, say a FORTRAN program. However, the development time needed for the MATLAB program may be significantly less if it makes extensive use of the MATLAB built-in functions. If the speed of the running program is not an issue, then MATLAB may be the better choice. Having said that, compilers are now available to allow MATLAB program files (M-files) to be run outside the MATLAB environment.
MATLABs basic data structure is a MATRIX. Even a single integer variable is treated as a matrix of one row and one column. This concept might take a while to get used to. Names in MATLAB are formed by a letter, followed by other letters, digits or underscores though only the first nineteen characters are recognised/significant. Importantly, unlike Fortran, MATLAB does distinguish between uppercase and lowercase letters. Thus the variables a and A in a MATLAB program would be different entities.
MECH1004
COMPUTING
MECH1004
COMPUTING
OTHER WINDOWS
Other windows will be displayed when you click on certain files (e.g. M-files) or activate certain functions (e.g. graph plotting functions). These can be re-arranged or closed as required.
MECH1004
COMPUTING
MECH1004
COMPUTING
Sample coding 2:(This could be typed in line by line in the command window or written to an m-file for repeated use.) % Simple sums x = 25.0 y = 33.9 z=x*y a=x+y A=y/x b = a * cos (30) c = A * sin (30) d=x^2 D = sqrt(y) e = sqrt(-1) NB different from FORTRAN which uses **
MECH1004
COMPUTING
MECH1004
COMPUTING
At this stage in your engineering education you will just have to take it on trust that it is because so many advanced maths and engineering type problems & solutions are so succinctly described by vector equations and algebra, that the writers of MATLAB decided to make the MATRIX the fundamental structure within their program. Well be looking at problem solving using matrices later. For now lets get familiar with how we can create matrices in MATLAB.