0% found this document useful (0 votes)
41 views19 pages

Chapter 1 - General Introduction

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views19 pages

Chapter 1 - General Introduction

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Chapter 1: General Introduction

CS10-8
Learning Goals

■ Introduce terminology used in computer science.


■ Describe the purpose of programming languages.
■ Distinguish between formal and natural language.
Algorithms

An algorithm is a step by step list of instructions that is


followed exactly to solve a specific problem.

Algorithms are like recipes; they must be followed exactly,


they must be clear and unambiguous, and they must end.
The Matlab Programming Language
You will be learning MATLAB. MATLAB is an example of a
high-level language. It is a high-level language and interactive
environment for numerical computation, visualization, and
programming.
Essentials of MATLAB® Programming, 3rd Edition Chapman

● MATLAB is short for MATrix LABoratory

● MATLAB is a combination of:

○ a procedural programming language

○ an integrated development environment (IDE) + editor and debugger

○ an extremely rich set of built-in functions to perform many types of technical calculations

© 2018 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Essentials of MATLAB® Programming, 3rd Edition Chapman

The Advantages of MATLAB

● Ease of Use – interpreted language, rapid prototyping


● Platform Independence – Windows, Linux, Unix, Macintosh
● Predefined Functions – extensive library, prepackaged solutions, special-purpose
toolboxes
● Device-Independent Plotting – display on any graphical output device
● Graphical User Interface – design sophisticated programs to be operated by any user
● MATLAB Compiler – speeds up interpreted language

© 2018 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Other High-Level Programming Languages

● C++ is a powerful general-purpose programming


language. It can be used to develop operating systems,
browsers, games, and so on. Created by (Bjarne
Stroustrup)
● PHP is a general-purpose scripting language that is
especially suited to web development. Created by
(Rasmus Lerdorf)
Other High-Level Programming Languages

● Java is a general-purpose programming language


intended to let application developers write once, run
anywhere (WORA), Created by James Gosling.
● Python is a language constructs and object-oriented
approach aim to help programmers write clear, logical
code for small and large-scale projects. (Created by Guido
van Rossum)
Two kinds of programs to process high-level language to
low-level language
1. Interpreters - reads a high-level program and executes it.
2. Compilers - reads the program and translates it
completely before the program starts running. In this case
the high-level program is the source code, and the
translated program is called the object code, or the
executable (JAVA and C++)
Two kinds of programs process high-level language to low-
level language
1. Interpreter

Output
Source
Interpreter
Code
“Helloworld”

Helloworld.m
Two kinds of programs process high-level language to low-
level language
2. Compiler

Source
Compiler Object Code Executor Output
Code

Helloworld.m Executable file


of hello world
More about programs

● Program is a sequence of instructions that specifies how to


perform a computation. The computation might be something
as complex as showing an html page in a browser.
● Input - Get data from the keyboard, a file or some other device.
● Output - Display data on the screen or send data to a file or
other device
More about programs

● Conditionals - check for certain conditions and execute the


appropriate sequence of statements.
● Repetition - Perform some action repeatedly, usually with some
variation
Formal and Natural Languages

● Natural language are the languages that people speak, such as


Filipino, English and Mandarin. They were evolved naturally.
● Formal languages are languages that are designed by people
for specific applications.

“Programming languages are formal languages that have been


designed to express computations.”
The difference between Formal and Natural
Languages

1. Ambiguity
2. Redundancy
3. Literalness
Comments
A comment in a computer program is text that is intended
only for the human reader - It is completely ignored by the
interpreter. In Matlab, the % token starts a comment. The rest
of the line is ignored.
Essentials of MATLAB® Programming, 3rd Edition Chapman

The MATLAB Environment


Workspace
Browser
shows variables
defined in
workspace
Current Folder
Browser
shows a list of the MATLAB
files in the current Editor
folder

MATLAB
Details Window
Command
displays
Window
properties of file
selected above

© 2018 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Essentials of MATLAB® Programming, 3rd Edition Chapman

A Few Important Commands

Function Description

demo run MATLAB’s built-in demonstrations

clc clear the Command Window

clf clear the contents of the current figure window

clear clear the variables in the workspace

control-c abort running program, returns a command prompt

diary keep track of everything done in MATLAB session

© 2018 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Essentials of MATLAB® Programming, 3rd Edition Chapman

Using MATLAB as a Calculator

● In its simplest form, MATLAB can be used as a calculator to perform mathematical calculations

● Use the symbols +, -, *, /, and ^ for addition, subtraction, multiplication, division, and
exponentiation respectively

● The value in ans can be used in later calculations. But be careful! Every time a new expression
without an equal sign is evaluated, the value saved in ans will be overwritten.

© 2018 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.

You might also like