Engr 0012 (04-1) LecNotes 09-01 loading data from files >> file_name = input( 'Enter data file name ==> ','s') Enter data file name ==> c:\temp\speed_mpg.dat.

Slides:



Advertisements
Similar presentations
Lecture 5.
Advertisements

Engr 0012 (04-1) LecNotes Engr 0012 (04-1) LecNotes Functional analysis y = f(x) things to do 1. sketch graph 2. find roots (zeros) 3. find.
M AT L AB Programming: scripts & functions. Scripts It is possible to achieve a lot simply by executing one command at a time on the command line (even.
Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
Introduction to Matlab EE 2303 Lab. MATLAB stands for “Matrix Laboratory” APPLICATIONS OF MATLAB:  Mathematical Calculations  Data Analysis & Visualization.
Al-Amer An Introduction to MATLAB Lesson 2: M-files Dr. Samir Al-Amer Term 061.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 19P. 1Winter Quarter MATLAB: Script and.
MATLAB’s extensive, device-independent plotting capabilities are one of its most powerful features. They make it very easy to plot any data at any time.
Introduction to Matlab Tutorial for CS4MN3/SE3X03 Wen Yu McMaster University.
Graphing & Interpreting Data
Section 5: Graphs in Science
Graphing in Science.
Graphing. Parts of a Graph X-Axis: A horizontal line. Y-Axis: A vertical line. Title: A name for the graph and shows what information should be found.
How do scientists show the results of investigations?
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
Engr 0012 (04-1) LecNotes working toward a script that will help analyze data “Big” steps in accomplishing goal 1. Load data from file (have already.
Graphs in Science You Can Do It!!!.
Frequency Polygons and Ogives
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
Aim: How do scientists interpret data (Part 3)? Do Now: Copy the following: Line Graph - A graph that is used to display data that shows how one variable.
Why are Graphs Useful? AA graph is a “picture” of your data. GGraphs can reveal patterns or trends that data tables cannot. TThe 3 types of graphs.
Section 2.4 Representing Data.
Introduction to Engineering MATLAB – 6 Script Files - 1 Agenda Script files.
MATLAB Tutorial EE 327 Signals and Systems 1. What is MATLAB? MATLAB – Matrix Laboratory The premier number-crunching software Extremely useful for signal.
INTRODUCTION TO MATLAB LAB# 01
Matlab Basics Tutorial. Vectors Let's start off by creating something simple, like a vector. Enter each element of the vector (separated by a space) between.
How to create a graph and how to interpret different graph designs
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
© SSER Ltd. How Science Works Principles of Graph Drawing.
16 Graph Skills How to read and understand advanced types of bar charts, area graphs, climographs and triangle graphs How to advance their skills of drawing.
Objective: Plot points and lines on a coordinate plane. Standards Addressed: G: Represent relationships with tables or graphs in the coordinate plane.
Engr 0012 (04-1) LecNotes script/function comparison scriptsfunctions Show program logic answer “what” questions Show program details answer “how”
Script M-Files Group of Matlab commands placed in a text file with a text editor. Matlab can open and execute the commands exactly as if they were entered.
Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.
Introduction to MATLAB ENGR 1181 MATLAB 1. Opening MATLAB  Students, please open MATLAB now.  CLICK on the shortcut icon → Alternatively, select… start/All.
Introduction to Programming Workshop 6 PHYS1101 Discovery Skills in Physics Dr. Nigel Dipper Room 125d
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
Master in Optical Fiber Communications and Photonic Technologies Foundations of Digital Transmission - Fall quarter Introduction to Matlab.
11/20/2015ENGR 111A - Fall MatLab – Palm Chapter 5 Curve Fitting Class 14.1 Palm Chapter:
Bar Graphs Used for comparing separate groups. Axes X- axis: independent variable (what the scientist controls) Horizontal D – dependent R – responding.
Graph: a visual display of information or data
Requirements of a good GRAPH. GRAPH  Title (usually “dependent” vs. “independent”)  Go Big (cover at least ½ the page in both directions) This increases.
Chapter One, Section 5: Graphs in Science
CSE123 Lecture 3 Files and File ManagementScripts.
Recap Chapter 5 “Plotting” Two Dimensional Plots Simple x-y Plots Titles, Labels and Grids Multiple Plots.
Graphs of Motion Physics Ms. Allison. General Graphing Rules Title Label x and y axis with units - Dependent variable is on the y-axis; independent is.
Files: By the end of this class you should be able to: Prepare for EXAM 1. create an ASCII file describe the nature of an ASCII text Use and describe string.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
Laboratory #1 LabVIEW Supplement Prepared by Tiffany Morris.
Introduction to MATLAB Section2, statistics course Third year biomedical dept. Dina El Kholy, Ahmed Dalal.
Graphs in Science Section 1.5.
Recap Functions with No input OR No output Determining The Number of Input and Output Arguments Local Variables Global Variables Creating ToolBox of Functions.
CSE 455 : Computer Vision MATLAB 101 Getting Started with MATLAB.
Graphing Linear Equations In Standard Form Ax + By = C.
Creating Graphs. Why do we make graphs? Creating Graphs To view the data in an organized understandable way.
MATLAB ® for Engineers, Holly Moore Fourth Edition, Global Edition © Pearson Education Limited 2015 All rights reserved. Figure 5.1 Simple Plot of Time.
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
Graphing. Line Graphs  Shows a relationship where the dependent variable changes due to a change in the independent variable  Can have more than one.
Structured Computer Programming EE 201 Introduction to MATLAB 7 for Engineers بسم الله الرحمن الرحيم King Abdulaziz University College of Engineering Dept.
4.1 NOTES. x-Axis – The horizontal line on the coordinate plane where y=0. y-Axis – The vertical line on the coordinate plane where x=0.
Topic: Lab Skills Aim: How can we create a graph?.
Great Graphs!!!!! Or … How to Impress Math and Science Teachers Or … How to Impress Math and Science Teachers.
How to Construct Data Tables and Graph Your Data Proper Methods for Basic Lab Skills.
Matlab Programming for Engineers
MATLAB: Script and Function Files
MATLAB: Script and Function Files
working toward a script that will help analyze data
Review Make sure current directory is set properly Create a diary
MATLAB: Script and Function Files
Using Script Files and Managing Data
Presentation transcript:

Engr 0012 (04-1) LecNotes loading data from files >> file_name = input( 'Enter data file name ==> ','s') Enter data file name ==> c:\temp\speed_mpg.dat file_name = c:\temp\speed_mpg.dat >> xydata = load(file_name) xydata = (contents of data file displayed) >> speed = xydata(:,1)' speed = >> mpg = xydata(:,2)' mpg =

Engr 0012 (04-1) LecNotes loading data from files >> file_name = input( 'Enter data file name ==> ','s') Enter data file name ==> c:\temp\speed_mpg.dat file_name = c:\temp\speed_mpg.dat asking user to identify the filename/path where data is kept 's' tells MATLAB the input data will be a string respond with file name and location path can be omitted if file is in current MATLAB directory response is assigned as a string to variable file_name

Engr 0012 (04-1) LecNotes loading data from files >> xydata = load(file_name) xydata = (contents of data file displayed) functional form of load command file_name must be a string identifying where file can be found contents of file assigned to designated variable name

Engr 0012 (04-1) LecNotes loading data from files >> speed = xydata(:,1)' speed = extracting x-y vectors and transposing in same step

Engr 0012 (04-1) LecNotes comparing two forms of load command load filename.dat xydata = load(file_name) filename.dat is the name of a file in the current workspace file_name is a string (variable) that points to the file file contents assigned to a new variable called filename file contents assigned to designated variable ( xydata ) “hardwired” - cannot change data file name generic - filename can be changed by asking user good when working directly in MATLAB workspace preferable for use in function to get data from any file

Engr 0012 (04-1) LecNotes displaying data in a graph >> plot(speed,mpg,'r*') x-variable y-variable symbol type

Engr 0012 (04-1) LecNotes displaying data in a graph 'r*'

Engr 0012 (04-1) LecNotes annotating your graph >> xname = input( 'Enter x-axis name ==> ','s'); Enter x-axis name ==> speed >> yname = input( 'Enter y-axis name ==> ','s'); Enter y-axis name ==> mpg >> graphname = input( 'Enter graph name ==> ','s'); Enter graph name ==> MPG versus Speed >> xlabel(xname) >> ylabel(yname) >> title(graphname)

Engr 0012 (04-1) LecNotes annotating your graph x-axis label y-axis label title not linear, i.e., not y = mx+b

Engr 0012 (04-1) LecNotes searching for a straight line >> semilogy(speed,mpg,'*r') note change in y-scale

Engr 0012 (04-1) LecNotes searching for a straight line >> loglog(speed,mpg,'*r') note change in both axis scales

Engr 0012 (04-1) LecNotes recap on data analysis to date 1. function to load data, extract x & y components, get indep var name, dep var name, data set title, and symbol type needs: results: xpts, ypts, xname, yname, graphname, symbol 2. script that calls get data function, asks user for choice of plot type (linear, semilog, log-log), and displays requested (annotated) plot