Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
65 views11 pages

Computing For Math and Statistics: Intro

This document provides an introduction to using MATLAB for numerical computing, mathematics, and statistics. It discusses MATLAB's capabilities for performing calculations, simple programming, and developing more advanced software. Key points covered include using MATLAB as a calculator, defining variables, using assignment statements, and writing script files to execute MATLAB commands from disk. The focus is on the basic concepts needed to get started with simple MATLAB programs without advanced features like conditional statements or loops.

Uploaded by

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

Computing For Math and Statistics: Intro

This document provides an introduction to using MATLAB for numerical computing, mathematics, and statistics. It discusses MATLAB's capabilities for performing calculations, simple programming, and developing more advanced software. Key points covered include using MATLAB as a calculator, defining variables, using assignment statements, and writing script files to execute MATLAB commands from disk. The focus is on the basic concepts needed to get started with simple MATLAB programs without advanced features like conditional statements or loops.

Uploaded by

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

Computing for Math and Statistics

Intro
Matlab
● Numerical computing environment
● Programming language
● Proprietary system
● Extensible
● Easy to start using
● Main strength: Linear Algebra (matrices),
numerical analysis
Matlab
● Can be used as calculator
● Or as a calculator on hormones
● Can be used to quickly try a couple of ideas
● Can be used to write a few simple programs
● Can be used to develop industrial strength
software
As a calculator
● Fire up matlab and type
– 1+1
● Or type
– sind(90)
– cos(0)
– tan(pi/4)
As a calculator
● Built-in functions
– sin, cos, etc, sind, cosd, etc
– sqrt, exp, nthroot
– floor, ceil, rem, sign
● Built-in commands
– clc (clear command window)
– clear (clear all variables)
– who (list all variables)
– whos (list them with size)
Simple Programming
● Simple programming, usually means a set of
simple calculations, without conditional
statements, loops, function calls, etc
● We need three more concepts:
– Variables
– Assignment operators (aka assignments)
– Script files (aka scripts)
Variables
● A variable is a place in the computer memory
● It has a name
– A combination of letters and digits (has to start with a letter)
● Can be defined by the user
– In matlab we define a new variable just by using it.
● There are variables defined by the system (predefined)
– Can be redefined, but it is a lousy idea
● A simple program can have dozens of them
– One has to be careful about having too many.
– It is better if they have easy to remember names.
Variables
● Variable names
– Start with a letter
– Can have many letters, digits, underscores
– No dots, commas, spaces, etc
– Up to 63 characters long
– Case sensitive
● Good idea for names to be
– Short, but descriptive
– Different from built-in variables
Assignments
● When we execute an assignment we save the value of
a calculation in this place in the computer memory
● It is represented by the symbol =
– Other languages use :=
● The command
– X=1+1
● Stores 2 in a place in memory named X
● We read “X becomes one plus one”
– Not X equals one plus one.
Script Files
● Script files (scripts for short) are files on the hard disk
or on a USB stick.
● They contain matlab commands
● If we run (execute) the script it is as if we just typed
the commands in the script file into the command
window.
● We can execute a script by clicking the play button (if
the file is currently in the editor)
● We can also execute it by typing its name.
Script Files
● Script files can be created in the matlab editor,
or any other editor
● Can be executed many times
● Very useful for testing and debugging
● We usually write simple programs in script files.
● For complex projects we use function files.
– For this you got to wait a few weeks.

You might also like