Matlab Chapter 1
Matlab Chapter 1
COLLEGE OF ENGINEERING
KNUST
1
Course Outline
Course Objectives
• To describe and explain some basic terminology used
in computer programming
• To write and run computer programs in MATLAB
Contact Hours
• Lectures (2 hrs)
• LAB / Tutorials (2 hrs)
2
Course Outline
Course Content
• Computer Programming Fundamentals
• Interactive MATLAB Programming
• Structured MATLAB Programming
Assessment
• Quizzes, Assignments, Mid-Semester, Final Exams
3
Assessment
• Quizzes, Assignments S1 = 30%
• Attendance
• End of Semester Exams (S2 = 70%)
• Final Score = S1 + S2
4
References
• Chapra, S.C., Applied Numerical Methods with
MATLAB for Engineers and Scientists, 3rd Int.
Ed., 2012
• Nakamura, S., Numerical Analysis and
Graphic Visualization with MATLAB, Prentice
Hall Inc. 1996
5
Computer Programming
Some Definitions
Computer Programming:
The process of creating a computer program
Computer Program:
A set of instructions that can be executed by
the computer to perform a specific task
Computer Software
A set of computer programs
6
Programming Languages
A programming language is a set of commands,
instructions, and other syntax used to create a computer
program (or software).
11
Compiled and Interpreted High-Level Languages
• A program written in a high-level language is called a source
program or source code
• A compiled language uses a tool known as a compiler to convert
the source code into machine code
A compiler translates the entire source code into a machine-
code file
• An interpreted language uses an interpreter to convert the
source code into machine code
An interpreter reads one statement from the source code,
translates it to machine code and then executes it right away
12
Classification of High-Level Languages
Language Uses a Compiler Uses an Interpreter
Pascal
FORTRAN
Visual Basic
C
C++
C#
Java
MATLAB
Python
Perl
Julia
Ruby 13
MATLAB Programming
• MATLAB stands for MATrix LABoratory
• MATLAB was invented by Cleve Moler in the late 1970s
• MATLAB is written in C.
• MATLAB works as an interpreter
• MATLAB codes run slower than codes written in C/C++ and
FORTRAN
• Uses of MATLAB
For Data Analysis
For developing algorithms
For creating models and applications 14
MATLAB Programming
• MATLAB is a multi-disciplinary tool
• Can be used in Numerical Computation Applications
• Has over 90 Toolboxes in multiple fields
Mathematics (Symbolic Math, Statistics, Curve Fitting, etc)
Communications & Signal Processing
Machine Vision (Image Processing, Computer Vision)
Statistics and Regression Analysis
Computational Finance
Instrument Control, Vehicle Dynamics, Aerospace, etc
15
MATLAB 2019 User Interface
Command
Window
Current
Folder
Workspace
16
Some Basic MATLAB Commands
who
Lists the names of the variables defined by the user
whos
Lists detailed information about the variables defined by
the user
clc
Clears the command window
17
Some Basic MATLAB Commands
clear
Deletes all the variables from the MATLAB workspace
What is a Matrix?
• A matrix is a one- or multi-dimensional array of elements
• All data in MATLAB are viewed as matrices
• Thus, a scalar is a matrix with only one row and one column
• A vector contains only one row or one column 20