MATLAB INTRODUCTION. Matlab can be used interactively as a super hand calculator, or, more powerfully, run using scripts (i.e., programs).

Size: px
Start display at page:

Download "MATLAB INTRODUCTION. Matlab can be used interactively as a super hand calculator, or, more powerfully, run using scripts (i.e., programs)."

Transcription

1 L A B 6 M A T L A B MATLAB INTRODUCTION Matlab is a commercial product that is used widely by students and faculty and researchers at UTEP. It provides a "high-level" programming environment for computing with a special emphasis on matrix operations. Many specialized functions are "hard wired" into Matlab so there is no need to use subroutine libraries for these tasks. It is also very easy to make plots of Matlab output-- many plotting functions are also built into the program. Matlab is available for PCs, Macs, and UNIX workstations. The student version of Matlab currently sells for about $100 at the UTEP bookstore. We have a site license for Matlab on the department network, however this is limited to university computers only. Matlab is more user-friendly and easier to learn than standard languages like Fortran and C. It is good for many problems, but ultimately does not have the flexibility of C or Fortran. Complicated Matlab scripts will often run much slower than the Fortran or C equivalent. Matlab is well documented with online help (look to the menu bar when you are running the program). There are also many books written about Matlab that you may find useful if you become a serious user. The following is a brief introduction to help you get started and to demonstrate some of Matlab s capabilities. Matlab can be used interactively as a super hand calculator, or, more powerfully, run using scripts (i.e., programs). PCs: A Matlab icon can be found on your desktop. Macs: Go to Macintosh HD Applications Matlab and drag the Matlab icon to your doc (for future use). Start Matlab and several blank screens, including a Command Window, should appear. Notes compiled by B. Konter (UTEP) and P. Shearer (UCSD)

2 Command window #1. Prompt and easy addition >> At the >> prompt, one can directly enter commands. As an example, the following is one way to compute 2+2: (Try it, you enter the bold, black info and Matlab returns the gray info) >> a = 2 a = 2 >> b = 2

3 b = 2 >> c = a + b c = 4 #2. The semi-colon (;) It is often annoying to have Matlab always print out the value of each variable. To avoid this, put a semicolon(;) after the commands: >> a = 2; >> b = 2; >> c = a + b; >> c c = 4 Only the final line produces output. Semicolons can also be used to string together more than one command on the same line: >> a = 2; b = 2; c = a + b; c c = 4 #3. More complicated math Now try an example for computing a quadratic equation, which includes multiplication (*), division (/), square-root (sqrt), and powers (^). Also note that parentheses are used to determine the order of operations. >> a = 2;

4 >> b = -12; >> c = 16; >> quad1 = (-b + sqrt(b^2-4*a*c)) / (2*a) quad1 = 4 #4. More complicated math: Trig functions Trig functions are also supported by Matlab. functions must be in radians, not degrees: Note that the arguments of trig >> y = sin (pi/6) y = Note that "pi" is hardwired to the value of pi (3.14..); you don't have to set this. #5. Whos (what are my variables?) To see all the variables currently defined in Matlab s current session (that you entered), use the "whos" command: >> whos Name Size Bytes Class a 1x1 8 double array b 1x1 8 double array c 1x1 8 double array quad1 1x1 8 double array y 1x1 8 double array To remove all variables from memory, use the "clear" command: >> clear

5 >> whos >> # 6. Using a Matlab script (*.m) file A script is a text file containing lines of Matlab commands (e.g. testscript.m). To run a script, simply type the name of your script, but without the.m suffix, at the Matlab prompt: >> testscript By doing this, Matlab simply executes each line one at a time, exactly as if you had typed each line into the command window. In your script, you can create lines beginning with a % sign, which are understood by Matlab to be comments about the code (and are ignored). Example: % At the first line of my code, I should always put my name % At the second line of my code, I should enter a % description of what the program is going to do. A script can be written with the built-in Matlab Editor, or you can open up an existing script that someone gave you. Here you will do both. First, make a new Lab6 folder in your geobase directory and copy to the Lab6 folder (yes, please copy) the following file from Bridget s geobase folder: bkonter/matlab_stuff/testscript.m To run a script, you need to tell Matlab where to look for the *.m files that you want to run. To do this, you ll want to set the Current Directory to your working folder, so for this exercise it will be your Lab6 folder on geobase. In the top Matlab window, look for the icon (see below) and click on it to navigate to your Lab6 folder. Next you will need to open up the Matlab Editor window: Window Editor.

6 A new, separate window should appear. Now open the testscript.m file: File Open select testscript.m Familiarize yourself with the content of the script (read through it), then run the program in the Matlab window by typing: >> testscript What did this program do? Draw a sketch of the resulting figure of testscript.m program below: # 7. Creating a new Matlab script (*.m) file Next you will create a new Matlab script to plot an example set of x-y data points. The file with these example points is called test_data.dat and is located in Bridget s Matlab folder. Copy this file to your own Lab6 folder. Open up test_data.dat file in the Matlab Editor to inspect its contents: File Open test_data.dat The first column of the data will be the x column (pretend it is earthquake

7 depths), and the second column of data will be the y column (pretend it represents earthquake magnitudes). You will use these values to create an x-y plot. Contents of test_data.dat: First open a new Matlab file in the Editor window: File New M-File Type the following commands in the Matlab file (yes, all of them): % Matlab script to practice loading a simple data file % and creating an x-y plot. % first load the sample data file, named test_data.dat load test_data.dat % assign the first column of this file to be x values % The following syntax says grab all rows (:) % of the first column (1) of the file test_data x = test_data(:,1); % next assign the second column of the file to be y % values y = test_data(:,2); % now check to make sure the data was loaded properly whos % now plot x vs. y and label each data point with a red *

8 % symbol. I can type help plot for other symbols and % colors to use figure(1) % opens up the first figure window plot (x,y, r* ) % plot x vs. y grid % this enters a grid in the figure xlabel( earthquake depths (km) ) % label the x-axis ylabel( earthquake magnitudes ) % label the y-axis title( Earthquakes in the xxx ) % add a title Save your Matlab file with the name myscript.m : File SaveAS Now copy each line, line by line, that does not begin with a % sign, into the Matlab window. Observe what each line does. Next clear Matlab (type: clear) and close the Figure window. Now run the entire script at once by typing the name of your script (without the.m ) into the Matlab window and hit return. Congratulations, you have just created and executed a Matlab script!!!!! To save your Figure to a file, click on the following in the Figure window: File SaveAs name it myscriptfigure and select.pdf option for File Format # 7. Performing math operations on a column of data Now you will practice a few math operations, just like you did in Excel, by treating each of your data values as a column that you will operate on. In the previous step, you stored all of the first column of data as x and the second column as y. Below are the steps for calculating the average of each and then normalizing (dividing) your data by the average. Matlab has a built-in function for computing the average (or mean) of a data set. First calculate the average of the x-values (you can hand-type these in or append them to your Matlab script above): >> avg_x = mean(x) Matlab returns (enter it here)

9 Now calculate the average of the y-values: >> avg_y = mean(y) Matlab returns (enter it here) Divide x by avg_x and call this a new variable. >> norm_x = x/avg_x Do the same for the y values: >> norm_y = y/avg_y Now print your new and old values to the screen: >> [x y norm_x norm_y] To save these values to a file, assign all of them one name (new_vals), and print the 4 columns to a file. Below are the commands to use. You will need to transpose your data columns (using the command) to ensure that the fprintf command below writes the data in the correct order. >> new_vals = [x y norm_x norm_y] ; % transpose here >> fid = fopen( mytest_data.dat, w+ ); >> fprintf(fid, %6.2f %6.2f %6.2f %6.2f\n, new_vals); >> fclose(fid); Note that in the above fprintf statement, you first give Matlab the command to open up a new, empty file. You specify the name of the new file with the first entry ( mytest_data.dat ). You also tell Matlab that you want to write to the new file with the w+ entry. Then you issue the print-to-this-file statement with the fprintf command. The fid entry just reminds Matlab where it stored the name of the new file in memory. A series of %6.2f are entered, which represents the format of each column that you are saving to the file (along with how many decimals to round to). If you were going to save 5 columns to a file, you d include 5 %6.2f entries, with the last one followed by a \n as in the example above (this means start a new line after the last column). Last, you enter the name of the

10 variable in Matlab that you want to print to the file. In this case, you assigned the name new_vals for the variable holding the 4 columns of data. For more information on the fprintf command, type help fprintf. Finally, you close the file that you first opened with the fclose command. # 8. Now you re on your own. Following the steps above, you will now use a real data file (the earthquakes you retrieved from the USGS website for the Excel Lab) to: - load into Matlab - plot the data - calculate the normalized depths and magnitudes - print the new values to a new file First copy the file called USGS_earthquakes.dat from Bridget s geobase Matlab folder, to your Lab6 folder. Open this file up in Matlab s Editor window and review the contents. columns are arranged in the following order: The Date (YYYYMMDD) Latitude Longitude Depths (km) Magnitudes Step 0. Write a Matlab script (name it *.m) that contains the commands for performing the following steps. Make sure you check your script by running it in Matlab. Also make sure to provide thorough comments in the script (denoted with a % symbol) that tell me what you are doing at each step. Step 1. Load the USGS_earthquakes.dat file in Matlab and assign variable names to each column of data. Hint: >> date = USGS_earthquakes(:,1); Step 2. Plot the Magnitudes vs. Depths of you data. Magnitudes should be along the horizontal axis, and Depths along the vertical. Plot each data point as a magenta ( m ) diamond. Give your plot x- and y-labels, a title, and a grid. Save this plot as a.pdf file. Step 3. Calculate the average of both your magnitudes data and your depth data. Then use these values to calculate normalized magnitudes and depths,

11 exactly as you did in Excel and in the previous example. Step 4. Assign a variable to store all of your original data, plus the two new columns of data (normalized values) you calculated. Hint: >> new_dat = [date latitude longitude mag depth norm_mag norm_depth] ; Step 5. Print the above (original data + new data) variable to a file. fprintf commands as given in the previous example. Use the Step 6. Post the following files to your Computer_Class folder on the web: - myscriptfigure.pdf (the figure resulting from running myscript.m) - mytest_data.dat (the new test data file you printed with the normalized values) - Earthquake Figure (the figure resulting from above, Section 8 Step 2) - New Earthquake file (the new file resulting from above, Section 8 Step 5). Extra Credit (1): What significant event is captured with this data? How do you know? Extra Credit (2): Try using the histogram function of Matlab. Look up the histogram function (hist) with the help command, and then use it to plot a histogram of your original earthquake depths and your original earthquake magnitudes (2 separate histograms). You can choose to bin the data however you like (but it should make some sense). For full credit, label your axes (with UNITS!!!), give your plots sensible titles, print them to pdf files, and post on your website.

12

1. Setup Everyone: Mount the /geobase/geo5215 drive and add a new Lab4 folder in you Labs directory.

1. Setup Everyone: Mount the /geobase/geo5215 drive and add a new Lab4 folder in you Labs directory. L A B 4 E X C E L For this lab, you will practice importing datasets into an Excel worksheet using different types of formatting. First, you will import data that is nicely organized at the source. Then

More information

Setup Mount the //geobase/geo4315 server and add a new Lab2 folder in your user folder.

Setup Mount the //geobase/geo4315 server and add a new Lab2 folder in your user folder. L AB 2 L AB M2 ICROSOFT E XCEL O FFICE W ORD, E XCEL & POWERP OINT XCEL & P For this lab, you will practice importing datasets into an Excel worksheet using different types of formatting. First, you will

More information

Programming 1. Script files. help cd Example:

Programming 1. Script files. help cd Example: Programming Until now we worked with Matlab interactively, executing simple statements line by line, often reentering the same sequences of commands. Alternatively, we can store the Matlab input commands

More information

A Guide to Using Some Basic MATLAB Functions

A Guide to Using Some Basic MATLAB Functions A Guide to Using Some Basic MATLAB Functions UNC Charlotte Robert W. Cox This document provides a brief overview of some of the essential MATLAB functionality. More thorough descriptions are available

More information

A/D Converter. Sampling. Figure 1.1: Block Diagram of a DSP System

A/D Converter. Sampling. Figure 1.1: Block Diagram of a DSP System CHAPTER 1 INTRODUCTION Digital signal processing (DSP) technology has expanded at a rapid rate to include such diverse applications as CDs, DVDs, MP3 players, ipods, digital cameras, digital light processing

More information

EOSC 352 MATLAB Review

EOSC 352 MATLAB Review EOSC 352 MATLAB Review To use MATLAB, you can either (1) type commands in the window (i.e., at the command line ) or (2) type in the name of a file you have made, whose name ends in.m and which contains

More information

1 Introduction to Matlab

1 Introduction to Matlab 1 Introduction to Matlab 1. What is Matlab? Matlab is a computer program designed to do mathematics. You might think of it as a super-calculator. That is, once Matlab has been started, you can enter computations,

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB Introduction: MATLAB is a powerful high level scripting language that is optimized for mathematical analysis, simulation, and visualization. You can interactively solve problems

More information

ECE 3793 Matlab Project 1

ECE 3793 Matlab Project 1 ECE 3793 Matlab Project 1 Spring 2017 Dr. Havlicek DUE: 02/04/2017, 11:59 PM Introduction: You will need to use Matlab to complete this assignment. So the first thing you need to do is figure out how you

More information

Programming in Mathematics. Mili I. Shah

Programming in Mathematics. Mili I. Shah Programming in Mathematics Mili I. Shah Starting Matlab Go to http://www.loyola.edu/moresoftware/ and login with your Loyola name and password... Matlab has eight main windows: Command Window Figure Window

More information

INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX

INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX 1) Objective The objective of this lab is to review how to access Matlab, Simulink, and the Communications Toolbox, and to become familiar

More information

Excel Primer CH141 Fall, 2017

Excel Primer CH141 Fall, 2017 Excel Primer CH141 Fall, 2017 To Start Excel : Click on the Excel icon found in the lower menu dock. Once Excel Workbook Gallery opens double click on Excel Workbook. A blank workbook page should appear

More information

Appendix A. Introduction to MATLAB. A.1 What Is MATLAB?

Appendix A. Introduction to MATLAB. A.1 What Is MATLAB? Appendix A Introduction to MATLAB A.1 What Is MATLAB? MATLAB is a technical computing environment developed by The Math- Works, Inc. for computation and data visualization. It is both an interactive system

More information

Dr Richard Greenaway

Dr Richard Greenaway SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 2 Basic MATLAB Operation Dr Richard Greenaway 2 Basic MATLAB Operation 2.1 Overview 2.1.1 The Command Line In this Workshop you will learn how

More information

Interactive MATLAB use. Often, many steps are needed. Automated data processing is common in Earth science! only good if problem is simple

Interactive MATLAB use. Often, many steps are needed. Automated data processing is common in Earth science! only good if problem is simple Chapter 2 Interactive MATLAB use only good if problem is simple Often, many steps are needed We also want to be able to automate repeated tasks Automated data processing is common in Earth science! Automated

More information

LAB 1 General MATLAB Information 1

LAB 1 General MATLAB Information 1 LAB 1 General MATLAB Information 1 General: To enter a matrix: > type the entries between square brackets, [...] > enter it by rows with elements separated by a space or comma > rows are terminated by

More information

STAT 391 Handout 1 Making Plots with Matlab Mar 26, 2006

STAT 391 Handout 1 Making Plots with Matlab Mar 26, 2006 STAT 39 Handout Making Plots with Matlab Mar 26, 26 c Marina Meilă & Lei Xu mmp@cs.washington.edu This is intended to help you mainly with the graphics in the homework. Matlab is a matrix oriented mathematics

More information

ENGR 1181 MATLAB 05: Input and Output

ENGR 1181 MATLAB 05: Input and Output ENGR 1181 MATLAB 05: Input and Output Learning Objectives 1. Create a basic program that can be used over and over or given to another person to use 2. Demonstrate proper use of the input command, which

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab Andreas C. Kapourani (Credit: Steve Renals & Iain Murray) 9 January 08 Introduction MATLAB is a programming language that grew out of the need to process matrices. It is used extensively

More information

MATLAB Tutorial III Variables, Files, Advanced Plotting

MATLAB Tutorial III Variables, Files, Advanced Plotting MATLAB Tutorial III Variables, Files, Advanced Plotting A. Dealing with Variables (Arrays and Matrices) Here's a short tutorial on working with variables, taken from the book, Getting Started in Matlab.

More information

Computational lab on complex numbers

Computational lab on complex numbers Computational lab on complex numbers SAK, physics 1140 March 15, 2010 1 Objective To learn how to use MATLAB as an advanced calculator and gain familiarity with complex numbers using MATLAB. 2 Introduction

More information

Class #15: Experiment Introduction to Matlab

Class #15: Experiment Introduction to Matlab Class #15: Experiment Introduction to Matlab Purpose: The objective of this experiment is to begin to use Matlab in our analysis of signals, circuits, etc. Background: Before doing this experiment, students

More information

Getting To Know Matlab

Getting To Know Matlab Getting To Know Matlab The following worksheets will introduce Matlab to the new user. Please, be sure you really know each step of the lab you performed, even if you are asking a friend who has a better

More information

Chapter 2. MATLAB Fundamentals

Chapter 2. MATLAB Fundamentals Chapter 2. MATLAB Fundamentals Choi Hae Jin Chapter Objectives q Learning how real and complex numbers are assigned to variables. q Learning how vectors and matrices are assigned values using simple assignment,

More information

MATLAB Project: Getting Started with MATLAB

MATLAB Project: Getting Started with MATLAB Name Purpose: To learn to create matrices and use various MATLAB commands for reference later MATLAB built-in functions used: [ ] : ; + - * ^, size, help, format, eye, zeros, ones, diag, rand, round, cos,

More information

Laboratory 1 Octave Tutorial

Laboratory 1 Octave Tutorial Signals, Spectra and Signal Processing Laboratory 1 Octave Tutorial 1.1 Introduction The purpose of this lab 1 is to become familiar with the GNU Octave 2 software environment. 1.2 Octave Review All laboratory

More information

Matlab for FMRI Module 1: the basics Instructor: Luis Hernandez-Garcia

Matlab for FMRI Module 1: the basics Instructor: Luis Hernandez-Garcia Matlab for FMRI Module 1: the basics Instructor: Luis Hernandez-Garcia The goal for this tutorial is to make sure that you understand a few key concepts related to programming, and that you know the basics

More information

PART 1 PROGRAMMING WITH MATHLAB

PART 1 PROGRAMMING WITH MATHLAB PART 1 PROGRAMMING WITH MATHLAB Presenter: Dr. Zalilah Sharer 2018 School of Chemical and Energy Engineering Universiti Teknologi Malaysia 23 September 2018 Programming with MATHLAB MATLAB Environment

More information

12 whereas if I terminate the expression with a semicolon, the printed output is suppressed.

12 whereas if I terminate the expression with a semicolon, the printed output is suppressed. Example 4 Printing and Plotting Matlab provides numerous print and plot options. This example illustrates the basics and provides enough detail that you can use it for typical classroom work and assignments.

More information

MATLAB TUTORIAL WORKSHEET

MATLAB TUTORIAL WORKSHEET MATLAB TUTORIAL WORKSHEET What is MATLAB? Software package used for computation High-level programming language with easy to use interactive environment Access MATLAB at Tufts here: https://it.tufts.edu/sw-matlabstudent

More information

MATLAB Project: Getting Started with MATLAB

MATLAB Project: Getting Started with MATLAB Name Purpose: To learn to create matrices and use various MATLAB commands for reference later MATLAB functions used: [ ] : ; + - * ^, size, help, format, eye, zeros, ones, diag, rand, round, cos, sin,

More information

Lab 1 Intro to MATLAB and FreeMat

Lab 1 Intro to MATLAB and FreeMat Lab 1 Intro to MATLAB and FreeMat Objectives concepts 1. Variables, vectors, and arrays 2. Plotting data 3. Script files skills 1. Use MATLAB to solve homework problems 2. Plot lab data and mathematical

More information

Getting Started. Chapter 1. How to Get Matlab. 1.1 Before We Begin Matlab to Accompany Lay s Linear Algebra Text

Getting Started. Chapter 1. How to Get Matlab. 1.1 Before We Begin Matlab to Accompany Lay s Linear Algebra Text Chapter 1 Getting Started How to Get Matlab Matlab physically resides on each of the computers in the Olin Hall labs. See your instructor if you need an account on these machines. If you are going to go

More information

Introduction to MatLab. Introduction to MatLab K. Craig 1

Introduction to MatLab. Introduction to MatLab K. Craig 1 Introduction to MatLab Introduction to MatLab K. Craig 1 MatLab Introduction MatLab and the MatLab Environment Numerical Calculations Basic Plotting and Graphics Matrix Computations and Solving Equations

More information

MATLAB BASICS. < Any system: Enter quit at Matlab prompt < PC/Windows: Close command window < To interrupt execution: Enter Ctrl-c.

MATLAB BASICS. < Any system: Enter quit at Matlab prompt < PC/Windows: Close command window < To interrupt execution: Enter Ctrl-c. MATLAB BASICS Starting Matlab < PC: Desktop icon or Start menu item < UNIX: Enter matlab at operating system prompt < Others: Might need to execute from a menu somewhere Entering Matlab commands < Matlab

More information

MATH (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab

MATH (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab MATH 495.3 (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab Below is a screen similar to what you should see when you open Matlab. The command window is the large box to the right containing the

More information

EGR 111 Functions and Relational Operators

EGR 111 Functions and Relational Operators EGR 111 Functions and Relational Operators This lab is an introduction to writing your own MATLAB functions. The lab also introduces relational operators and logical operators which allows MATLAB to compare

More information

Getting Started with MATLAB

Getting Started with MATLAB Getting Started with MATLAB Math 315, Fall 2003 Matlab is an interactive system for numerical computations. It is widely used in universities and industry, and has many advantages over languages such as

More information

Introduction to Matlab

Introduction to Matlab What is Matlab? Introduction to Matlab Matlab is software written by a company called The Mathworks (mathworks.com), and was first created in 1984 to be a nice front end to the numerical routines created

More information

MATLAB Fundamentals. Berlin Chen Department of Computer Science & Information Engineering National Taiwan Normal University

MATLAB Fundamentals. Berlin Chen Department of Computer Science & Information Engineering National Taiwan Normal University MATLAB Fundamentals Berlin Chen Department of Computer Science & Information Engineering National Taiwan Normal University Reference: 1. Applied Numerical Methods with MATLAB for Engineers, Chapter 2 &

More information

MATLAB Introduction. Contents. Introduction to Matlab. Published on Advanced Lab (

MATLAB Introduction. Contents. Introduction to Matlab. Published on Advanced Lab ( Published on Advanced Lab (http://experimentationlab.berkeley.edu) Home > References > MATLAB Introduction MATLAB Introduction Contents 1 Introduction to Matlab 1.1 About Matlab 1.2 Prepare Your Environment

More information

Data and Function Plotting with MATLAB (Linux-10)

Data and Function Plotting with MATLAB (Linux-10) Data and Function Plotting with MATLAB (Linux-10) This tutorial describes the use of MATLAB for general plotting of experimental data and equations and for special plots like histograms. (Astronomers -

More information

A Brief Introduction to MATLAB

A Brief Introduction to MATLAB A Brief Introduction to MATLAB MATLAB (Matrix Laboratory) is an interactive software system for numerical computations and graphics. As the name suggests, MATLAB was first designed for matrix computations:

More information

Math 2250 MATLAB TUTORIAL Fall 2005

Math 2250 MATLAB TUTORIAL Fall 2005 Math 2250 MATLAB TUTORIAL Fall 2005 Math Computer Lab The Mathematics Computer Lab is located in the T. Benny Rushing Mathematics Center (located underneath the plaza connecting JWB and LCB) room 155C.

More information

Matlab Tutorial and Exercises for COMP61021

Matlab Tutorial and Exercises for COMP61021 Matlab Tutorial and Exercises for COMP61021 1 Introduction This is a brief Matlab tutorial for students who have not used Matlab in their programming. Matlab programming is essential in COMP61021 as a

More information

Computer Project: Getting Started with MATLAB

Computer Project: Getting Started with MATLAB Computer Project: Getting Started with MATLAB Name Purpose: To learn to create matrices and use various MATLAB commands. Examples here can be useful for reference later. MATLAB functions: [ ] : ; + - *

More information

EE 216 Experiment 1. MATLAB Structure and Use

EE 216 Experiment 1. MATLAB Structure and Use EE216:Exp1-1 EE 216 Experiment 1 MATLAB Structure and Use This first laboratory experiment is an introduction to the use of MATLAB. The basic computer-user interfaces, data entry techniques, operations,

More information

MATLAB Introduction to MATLAB Programming

MATLAB Introduction to MATLAB Programming MATLAB Introduction to MATLAB Programming MATLAB Scripts So far we have typed all the commands in the Command Window which were executed when we hit Enter. Although every MATLAB command can be executed

More information

Matlab programming, plotting and data handling

Matlab programming, plotting and data handling Matlab programming, plotting and data handling Andreas C. Kapourani (Credit: Steve Renals & Iain Murray) 25 January 27 Introduction In this lab session, we will continue with some more sophisticated matrix

More information

Introduction to MATLAB

Introduction to MATLAB ELG 3125 - Lab 1 Introduction to MATLAB TA: Chao Wang (cwang103@site.uottawa.ca) 2008 Fall ELG 3125 Signal and System Analysis P. 1 Do You Speak MATLAB? MATLAB - The Language of Technical Computing ELG

More information

Desktop Command window

Desktop Command window Chapter 1 Matlab Overview EGR1302 Desktop Command window Current Directory window Tb Tabs to toggle between Current Directory & Workspace Windows Command History window 1 Desktop Default appearance Command

More information

Introduction to Matlab to Accompany Linear Algebra. Douglas Hundley Department of Mathematics and Statistics Whitman College

Introduction to Matlab to Accompany Linear Algebra. Douglas Hundley Department of Mathematics and Statistics Whitman College Introduction to Matlab to Accompany Linear Algebra Douglas Hundley Department of Mathematics and Statistics Whitman College August 27, 2018 2 Contents 1 Getting Started 5 1.1 Before We Begin........................................

More information

Creates a 1 X 1 matrix (scalar) with a value of 1 in the column 1, row 1 position and prints the matrix aaa in the command window.

Creates a 1 X 1 matrix (scalar) with a value of 1 in the column 1, row 1 position and prints the matrix aaa in the command window. EE 350L: Signals and Transforms Lab Spring 2007 Lab #1 - Introduction to MATLAB Lab Handout Matlab Software: Matlab will be the analytical tool used in the signals lab. The laboratory has network licenses

More information

0 Graphical Analysis Use of Excel

0 Graphical Analysis Use of Excel Lab 0 Graphical Analysis Use of Excel What You Need To Know: This lab is to familiarize you with the graphing ability of excels. You will be plotting data set, curve fitting and using error bars on the

More information

Importing and Exporting Data

Importing and Exporting Data Class14 Importing and Exporting Data MATLAB is often used for analyzing data that was recorded in experiments or generated by other computer programs. Likewise, data that is produced by MATLAB sometimes

More information

Math Scientific Computing - Matlab Intro and Exercises: Spring 2003

Math Scientific Computing - Matlab Intro and Exercises: Spring 2003 Math 64 - Scientific Computing - Matlab Intro and Exercises: Spring 2003 Professor: L.G. de Pillis Time: TTh :5pm 2:30pm Location: Olin B43 February 3, 2003 Matlab Introduction On the Linux workstations,

More information

Colorado State University Department of Mechanical Engineering. MECH Laboratory Exercise #1 Introduction to MATLAB

Colorado State University Department of Mechanical Engineering. MECH Laboratory Exercise #1 Introduction to MATLAB Colorado State University Department of Mechanical Engineering MECH 417 - Laboratory Exercise #1 Introduction to MATLAB Contents 1) Vectors and Matrices... 2 2) Polynomials... 3 3) Plotting and Printing...

More information

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University Part 1 Chapter 2 MATLAB Fundamentals PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

More information

Week 1: Introduction to R, part 1

Week 1: Introduction to R, part 1 Week 1: Introduction to R, part 1 Goals Learning how to start with R and RStudio Use the command line Use functions in R Learning the Tools What is R? What is RStudio? Getting started R is a computer program

More information

Experiment 1: Introduction to MATLAB I. Introduction. 1.1 Objectives and Expectations: 1.2 What is MATLAB?

Experiment 1: Introduction to MATLAB I. Introduction. 1.1 Objectives and Expectations: 1.2 What is MATLAB? Experiment 1: Introduction to MATLAB I Introduction MATLAB, which stands for Matrix Laboratory, is a very powerful program for performing numerical and symbolic calculations, and is widely used in science

More information

Unix Computer To open MATLAB on a Unix computer, click on K-Menu >> Caedm Local Apps >> MATLAB.

Unix Computer To open MATLAB on a Unix computer, click on K-Menu >> Caedm Local Apps >> MATLAB. MATLAB Introduction This guide is intended to help you start, set up and understand the formatting of MATLAB before beginning to code. For a detailed guide to programming in MATLAB, read the MATLAB Tutorial

More information

An Introductory Tutorial on Matlab

An Introductory Tutorial on Matlab 1. Starting Matlab An Introductory Tutorial on Matlab We follow the default layout of Matlab. The Command Window is used to enter MATLAB functions at the command line prompt >>. The Command History Window

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB The Desktop When you start MATLAB, the desktop appears, containing tools (graphical user interfaces) for managing files, variables, and applications associated with MATLAB. The following

More information

ECON 502 INTRODUCTION TO MATLAB Nov 9, 2007 TA: Murat Koyuncu

ECON 502 INTRODUCTION TO MATLAB Nov 9, 2007 TA: Murat Koyuncu ECON 502 INTRODUCTION TO MATLAB Nov 9, 2007 TA: Murat Koyuncu 0. What is MATLAB? 1 MATLAB stands for matrix laboratory and is one of the most popular software for numerical computation. MATLAB s basic

More information

Pre-Lab Excel Problem

Pre-Lab Excel Problem Pre-Lab Excel Problem Read and follow the instructions carefully! Below you are given a problem which you are to solve using Excel. If you have not used the Excel spreadsheet a limited tutorial is given

More information

Chapter 1 Introduction to MATLAB

Chapter 1 Introduction to MATLAB Chapter 1 Introduction to MATLAB 1.1 What is MATLAB? MATLAB = MATrix LABoratory, the language of technical computing, modeling and simulation, data analysis and processing, visualization and graphics,

More information

MATLAB Introductory Course Computer Exercise Session

MATLAB Introductory Course Computer Exercise Session MATLAB Introductory Course Computer Exercise Session This course is a basic introduction for students that did not use MATLAB before. The solutions will not be collected. Work through the course within

More information

Quick MATLAB Syntax Guide

Quick MATLAB Syntax Guide Quick MATLAB Syntax Guide Some useful things, not everything if-statement Structure: if (a = = = ~=

More information

MATLAB Tutorial. Primary Author: Shoumik Chatterjee Secondary Author: Dr. Chuan Li

MATLAB Tutorial. Primary Author: Shoumik Chatterjee Secondary Author: Dr. Chuan Li MATLAB Tutorial Primary Author: Shoumik Chatterjee Secondary Author: Dr. Chuan Li 1 Table of Contents Section 1: Accessing MATLAB using RamCloud server...3 Section 2: MATLAB GUI Basics. 6 Section 3: MATLAB

More information

Matlab Tutorial 1: Working with variables, arrays, and plotting

Matlab Tutorial 1: Working with variables, arrays, and plotting Matlab Tutorial 1: Working with variables, arrays, and plotting Setting up Matlab First of all, let's make sure we all have the same layout of the different windows in Matlab. Go to Home Layout Default.

More information

Matlab notes Matlab is a matrix-based, high-performance language for technical computing It integrates computation, visualisation and programming usin

Matlab notes Matlab is a matrix-based, high-performance language for technical computing It integrates computation, visualisation and programming usin Matlab notes Matlab is a matrix-based, high-performance language for technical computing It integrates computation, visualisation and programming using familiar mathematical notation The name Matlab stands

More information

= 3 + (5*4) + (1/2)*(4/2)^2.

= 3 + (5*4) + (1/2)*(4/2)^2. Physics 100 Lab 1: Use of a Spreadsheet to Analyze Data by Kenneth Hahn and Michael Goggin In this lab you will learn how to enter data into a spreadsheet and to manipulate the data in meaningful ways.

More information

Computational Mathematics/Information Technology. Worksheet 2 Iteration and Excel

Computational Mathematics/Information Technology. Worksheet 2 Iteration and Excel Computational Mathematics/Information Technology Worksheet 2 Iteration and Excel This sheet uses Excel and the method of iteration to solve the problem f(x) = 0. It introduces user functions and self referencing

More information

Using the fprintf command to save output to a file.

Using the fprintf command to save output to a file. Using the fprintf command to save output to a file. In addition to displaying output in the Command Window, the fprintf command can be used for writing the output to a file when it is necessary to save

More information

Prof. Manoochehr Shirzaei. RaTlab.asu.edu

Prof. Manoochehr Shirzaei. RaTlab.asu.edu RaTlab.asu.edu Introduction To MATLAB Introduction To MATLAB This lecture is an introduction of the basic MATLAB commands. We learn; Functions Procedures for naming and saving the user generated files

More information

Finding MATLAB on CAEDM Computers

Finding MATLAB on CAEDM Computers Lab #1: Introduction to MATLAB Due Tuesday 5/7 at noon This guide is intended to help you start, set up and understand the formatting of MATLAB before beginning to code. For a detailed guide to programming

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab Kristian Sandberg Department of Applied Mathematics University of Colorado Goal The goal with this worksheet is to give a brief introduction to the mathematical software Matlab.

More information

ERTH3021 Exploration and Mining Geophysics

ERTH3021 Exploration and Mining Geophysics ERTH3021 Exploration and Mining Geophysics Practical 1: Introduction to Scientific Programming using Python Purposes To introduce simple programming skills using the popular Python language. To provide

More information

Introduction to Matlab. By: Dr. Maher O. EL-Ghossain

Introduction to Matlab. By: Dr. Maher O. EL-Ghossain Introduction to Matlab By: Dr. Maher O. EL-Ghossain Outline: q What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display Facilities Flow Control

More information

1-- Pre-Lab The Pre-Lab this first week is short and straightforward. Make sure that you read through the information below prior to coming to lab.

1-- Pre-Lab The Pre-Lab this first week is short and straightforward. Make sure that you read through the information below prior to coming to lab. EELE 477 Lab 1: Introduction to MATLAB Pre-Lab and Warm-Up: You should read the Pre-Lab and Warm-up sections of this lab assignment and go over all exercises in the Pre-Lab section before attending your

More information

MAT 275 Laboratory 1 Introduction to MATLAB

MAT 275 Laboratory 1 Introduction to MATLAB MATLAB sessions: Laboratory 1 1 MAT 275 Laboratory 1 Introduction to MATLAB MATLAB is a computer software commonly used in both education and industry to solve a wide range of problems. This Laboratory

More information

APPM 2460 Matlab Basics

APPM 2460 Matlab Basics APPM 2460 Matlab Basics 1 Introduction In this lab we ll get acquainted with the basics of Matlab. This will be review if you ve done any sort of programming before; the goal here is to get everyone on

More information

EEE161 Applied Electromagnetics Laboratory 1

EEE161 Applied Electromagnetics Laboratory 1 EEE161 Applied Electromagnetics Laboratory 1 Instructor: Dr. Milica Marković Office: Riverside Hall 3028 Email: milica@csus.edu Web:http://gaia.ecs.csus.edu/ milica This laboratory exercise will introduce

More information

Laboratory 1 Introduction to MATLAB for Signals and Systems

Laboratory 1 Introduction to MATLAB for Signals and Systems Laboratory 1 Introduction to MATLAB for Signals and Systems INTRODUCTION to MATLAB MATLAB is a powerful computing environment for numeric computation and visualization. MATLAB is designed for ease of use

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB Introduction MATLAB is an interactive package for numerical analysis, matrix computation, control system design, and linear system analysis and design available on most CAEN platforms

More information

Objectives. 1 Running, and Interface Layout. 2 Toolboxes, Documentation and Tutorials. 3 Basic Calculations. PS 12a Laboratory 1 Spring 2014

Objectives. 1 Running, and Interface Layout. 2 Toolboxes, Documentation and Tutorials. 3 Basic Calculations. PS 12a Laboratory 1 Spring 2014 PS 12a Laboratory 1 Spring 2014 Objectives This session is a tutorial designed to a very quick overview of some of the numerical skills that you ll need to get started. Throughout the tutorial, the instructors

More information

Matlab Tutorial: Basics

Matlab Tutorial: Basics Matlab Tutorial: Basics Topics: opening matlab m-files general syntax plotting function files loops GETTING HELP Matlab is a program which allows you to manipulate, analyze and visualize data. MATLAB allows

More information

This module aims to introduce Precalculus high school students to the basic capabilities of Matlab by using functions. Matlab will be used in

This module aims to introduce Precalculus high school students to the basic capabilities of Matlab by using functions. Matlab will be used in This module aims to introduce Precalculus high school students to the basic capabilities of Matlab by using functions. Matlab will be used in subsequent modules to help to teach research related concepts

More information

Reference and Style Guide for Microsoft Excel

Reference and Style Guide for Microsoft Excel Reference and Style Guide for Microsoft Excel TABLE OF CONTENTS Getting Acquainted 2 Basic Excel Features 2 Writing Cell Equations Relative and Absolute Addresses 3 Selecting Cells Highlighting, Moving

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB MATLAB stands for MATrix LABoratory. Originally written by Cleve Moler for college linear algebra courses, MATLAB has evolved into the premier software for linear algebra computations

More information

Lab 1 Introduction to MATLAB and Scripts

Lab 1 Introduction to MATLAB and Scripts Lab 1 Introduction to MATLAB and Scripts EE 235: Continuous-Time Linear Systems Department of Electrical Engineering University of Washington The development of these labs was originally supported by the

More information

ME1107 Computing Y Yan.

ME1107 Computing Y Yan. ME1107 Computing 1 2008-2009 Y Yan http://www.staff.city.ac.uk/~ensyy About Fortran Fortran Formula Translation High level computer language Basic, Fortran, C, C++, Java, C#, (Matlab) What do we learn?

More information

Matlab Programming Arrays and Scripts 1 2

Matlab Programming Arrays and Scripts 1 2 Matlab Programming Arrays and Scripts 1 2 Mili I. Shah September 10, 2009 1 Matlab, An Introduction with Applications, 2 nd ed. by Amos Gilat 2 Matlab Guide, 2 nd ed. by D. J. Higham and N. J. Higham Matrix

More information

Introduction to MATLAB Practical 1

Introduction to MATLAB Practical 1 Introduction to MATLAB Practical 1 Daniel Carrera November 2016 1 Introduction I believe that the best way to learn Matlab is hands on, and I tried to design this practical that way. I assume no prior

More information

Adobe Dreamweaver CS5 Tutorial

Adobe Dreamweaver CS5 Tutorial Adobe Dreamweaver CS5 Tutorial GETTING STARTED This tutorial focuses on the basic steps involved in creating an attractive, functional website. In using this tutorial you will learn to design a site layout,

More information

Teaching Manual Math 2131

Teaching Manual Math 2131 Math 2131 Linear Algebra Labs with MATLAB Math 2131 Linear algebra with Matlab Teaching Manual Math 2131 Contents Week 1 3 1 MATLAB Course Introduction 5 1.1 The MATLAB user interface...........................

More information

1 Introduction. 2 Useful linear algebra (reprise) Introduction to MATLAB Reading. Spencer and Ware (2008), secs. 1-7, 9-9.3,

1 Introduction. 2 Useful linear algebra (reprise) Introduction to MATLAB Reading. Spencer and Ware (2008), secs. 1-7, 9-9.3, Introduction to MATLAB Reading Spencer and Ware (2008), secs. 1-7, 9-9.3, 12-12.4. For reference: matlab online help desk 1 Introduction MATLAB is commercial software that provides a computing environment

More information

PC-MATLAB PRIMER. This is intended as a guided tour through PCMATLAB. Type as you go and watch what happens.

PC-MATLAB PRIMER. This is intended as a guided tour through PCMATLAB. Type as you go and watch what happens. PC-MATLAB PRIMER This is intended as a guided tour through PCMATLAB. Type as you go and watch what happens. >> 2*3 ans = 6 PCMATLAB uses several lines for the answer, but I ve edited this to save space.

More information

ENGR Fall Exam 1

ENGR Fall Exam 1 ENGR 1300 Fall 01 Exam 1 INSTRUCTIONS: Duration: 60 minutes Keep your eyes on your own work! Keep your work covered at all times! 1. Each student is responsible for following directions. Read carefully..

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab 1 Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display Facilities Flow Control Using of M-File Writing User

More information