Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Engineering
Education
1s
A bit is the most basic unit of computing and
0s
Has a value of 0 (false) or 1 (true)
Collections of bits called a word (e.g. 011 or 11010101)
Multiple bits can be strung together to form bigger units
Bytes (8 bits)
Kilobytes (1000 bytes)
Megabytes (1000 kilobytes)... etc
Engineering
Education
ABCs
Some Basic Data Types and
123s
Boolean
Single bit, 1 = true, 0 = false
Integer
Whole numbers
Signed (can be negative) or Unsigned (cant be negative)
Decimal
Real numbers
Characters
Letters (A B C x y z) and symbols (, . / ! ?)
Engineering
Education
ABCs
Data Types - Example and
123s
10010011
Unsigned integer 147
Signed integer -109
ASCII extended character
The point
We need to know what the 1s and 0s represent to make sense of them, use
computers for anything besides binary operations
Engineering
Education
Problems 1 and 2
Engineering
Education
Programming
MATLAB Syntax - Variables
Engineering
Education
Programming
MATLAB Syntax - Semicolons
In general, you will want to put a semicolon (;) at the end of every line
of code that assigns a value to a variable
Suppresses output
Forgetting this
Wont stop your program from running
Will give you a headache
Engineering
Education
Programming
MATLAB Syntax Operators
Basic arithmetic
Addition (+): x = 1+1;
Subtraction (-): x = 2-6;
Multiplication (*): z = 400*10;
Division (/): oneThird = x/3;
Exponents
Use the carrot (^): twoSquared = 2^2;
Engineering
Education
Programming
MATLAB Style - Comments
Engineering
Education
Programming
MATLAB Style Why?
%This simple script x = 20;
calculates the distance a y = 45;
vehicle can travel.
z = x * y;
gasTankSize = 20; %Gas tank
volume in gallons
fuelEfficiency = 45;
%Engine efficiency in miles
per gallon
distance = gasTankSize *
fuelEfficiency; %The range
of the vehicle
Engineering
Education