{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

02 Matlab Basics

# 02 Matlab Basics - 2 MATLAB Basics This chapter discusses...

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

2 - MATLAB Basics -1 2 - MATLAB Basics This chapter discusses some basic features of MATLAB programming, including 1. Arithmetic operations 2. Variable assignment 3. Arrays MATLAB as a calculator MATLAB is an interpreter . That means you can type text to it and receive output right away, like a pocket calculator. By contrast, FORTRAN, C, and Java require you to compile your program before you can run it. To begin this discussion, let’s assume we are purchasing rolling stock for a railroad company. We buy 4 tanker cars at a cost of \$25.5K each, 6 box cars at a cost of \$22K each and 2 refrigeration cars at a cost of \$50K each. To compute our total cost for this purchase, we could use MATLAB like we would a hand-held calculator; in the MATLAB command window, we’d enter the following at the prompt ( >> ): >> 4 * 25.5 + 6 * 22 + 2 * 50 and the monitor would display ans = 334 The number 334 is our cost (expressed in units of \$1,000). It is called a constant . The ans (short for answer) is a variable . The constant 334 is assigned to the variable ans by the equal sign. The variable name ans is what MATLAB uses as a default output variable. ans is actually a reference to the memory address where 334 is stored for our use

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.

{[ snackBarMessage ]}

### Page1 / 4

02 Matlab Basics - 2 MATLAB Basics This chapter discusses...

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

View Full Document
Ask a homework question - tutors are online