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

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

View Full Document Right Arrow Icon
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*2 5 . 5+6*2 2+2*5 0 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
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/12/2011 for the course E 7 taught by Professor Patzek during the Spring '08 term at University of California, Berkeley.

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 Right Arrow Icon
Ask a homework question - tutors are online