Calculations and Variable Types

# Calculations and Variable Types - Variable Types...

This preview shows pages 1–6. Sign up to view the full content.

Variable Types Calculations Variable Types and Calculations T. Mercker Aerospace Engineering and Engineering Mechanics The University of Texas at Austin ASE 201: Introduction to Computer Programming January 30, 2009 T. Mercker Variable Types and Calculations

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Variable Types Calculations Outline Variable Types double and arrays char Calculations Scalar Calculations Array Arithmetic Reading: 2.1, 2.2, 2.8-2.10 T. Mercker Variable Types and Calculations
Variable Types Calculations double and arrays char Variable Types I How does MATLAB distinguish between x = 5 and x = ‘Hello’? I In this case, one version of x is a number and the other version is a character string I MATLAB differentiates by identifying each variable with a “class” I Some common classes we will work with are: I double (includes arrays) I char (character string) I sym (symbolic) I logical I Some other classes we will not work with are: cell, struct and function_handle I The class of a particular variable is available in the workspace I For now, we will focus on double and char T. Mercker Variable Types and Calculations

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Variable Types Calculations double and arrays char double class I MATLAB gives any numerical value the designation “double” I This differs from other programming languages in that all numerical values have to be pre-speciﬁed and could not change within a program I Classes in other languages include: I int (signed integer, used mostly for indices and counters) I uint (unsigned integer, only positive integers) I single (single precision, fewer number of digits) I etc. I Specifying is annoying but it saves memory (not necessary to carry 16 digits for integers) I MATLAB has the same designations available but it defaults to double I double allows for storing exact values up to 2 53 - 1 I Any value above this number is subject to truncation error T. Mercker Variable Types and Calculations
Variable Types Calculations double and arrays

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 04/29/2009 for the course ASE 201 taught by Professor Hayes during the Spring '07 term at University of Texas.

### Page1 / 16

Calculations and Variable Types - Variable Types...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online