Matlab DIY Lesson 1: Reading Data. Purpose of this Seminar Basic Ability to handle Data Analysis and Presentation in Matlab Understand how data is organized.

Slides:



Advertisements
Similar presentations
Chapter 3 Objects, types, and values Bjarne Stroustrup
Advertisements

Introduction to C Programming
Introduction to R Brody Sandel. Topics Approaching your analysis Basic structure of R Basic programming Plotting Spatial data.
Matlab Tutorial Course
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.
1 Arrays in JavaScript Name of array (Note that all elements of this array have the same name, c ) Position number of the element within array c c[6] c[0]
Matlab DIY Lesson 3: Parsing data. Today's Lesson “ parse ” = analyze into its parts o Sort the data you want MATLAB to use o Designate different segments.
CMT Programming Software Applications
Lesson 2: Basic Output You’ve got data……now what???
Lesson 2: Basic Output You’ve got data……now what???
Overview of C++ Chapter 2 in both books programs from books keycode for lab: get Program 1 from web test files.
Fall 2006AE6382 Design Computing1 Matlab File & Directory Management Learning Objectives Define file input and output terminology Compare high and low.
Chapter 2: Introduction to C++.
C++ for Engineers and Scientists Third Edition
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
Baburao Kamble (Ph.D) University of Nebraska-Lincoln Data Analysis Using R Week2: Data Structure, Types and Manipulation in R.
Introduction to Python Lecture 1. CS 484 – Artificial Intelligence2 Big Picture Language Features Python is interpreted Not compiled Object-oriented language.
THE MATLAB ENVIRONMENT VARIABLES BASIC COMMANDS HELP HP 100 – MATLAB Wednesday, 8/27/2014
Chapter 7: Arrays. In this chapter, you will learn about: One-dimensional arrays Array initialization Declaring and processing two-dimensional arrays.
REVIEW 2 Exam History of Computers 1. CPU stands for _______________________. a. Counter productive units b. Central processing unit c. Copper.
 For Loops › for (variable set; condition; incremental or decrement){ // loop beginning › } // loop end  While loops › while (condition) { // beginning.
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
Class 3 Programming in Visual Basic. Class Objectives Learn about input/output Learn about strings Learn about subroutines Learn about arrays Learn about.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
Introduction to File I/O High-Level Functions 1.Data files 2."High level" File I/O 3.dlmread() 4.xlsread() 1.
CSE 1301 Lecture 2 Data Types Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
Matlab Workshop 1/10/07 Lesson 1: Matlab as a graphing calculator.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room , Chris Hill, Room ,
CS346 Javascript -3 Module 3 JavaScript Variables.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to C++
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
C# C1 CSC 298 Elements of C# code (part 1). C# C2 Style for identifiers  Identifier: class, method, property (defined shortly) or variable names  class,
Using Text Files in Excel File I/O Methods. Working With Text Files A file can be accessed in any of three ways: –Sequential access: By far the most common.
COMP 116: Introduction to Scientific Programming Lecture 29: File I/O.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
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.
INTRODUCTION TO MATLAB DAVID COOPER SUMMER Course Layout SundayMondayTuesdayWednesdayThursdayFridaySaturday 67 Intro 89 Scripts 1011 Work
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Managers and “mentors” identified on projects page. All member accounts created and projects populated.
Digital Image Processing Introduction to MATLAB. Background on MATLAB (Definition) MATLAB is a high-performance language for technical computing. The.
 Variables can store data of different types, and different data types can do different things.  PHP supports the following data types:  String  Integer.
Characters and Strings
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
CS 106 Introduction to Computer Science I 09 / 10 / 2007 Instructor: Michael Eckmann.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Introduction to C++
CS 106 Introduction to Computer Science I 01 / 24 / 2007 Instructor: Michael Eckmann.
An Introduction to Programming in Matlab Emily Blumenthal
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
INTRODUCTION TO SPREADSHEET APPLICATIONS
An Example to Show Command-Line Arguments and Wrapper Class
Introduction to MATLAB
Jeff Henrikson Lecture 11 Data Import & Export Jeff Henrikson 1.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Advanced Data Import & Export Jeff Henrikson
2.1 Parts of a C++ Program.
WEB PROGRAMMING JavaScript.
Use of Mathematics using Technology (Maltlab)
Note on Indexing of Array Elements
Introduction to MATLAB
Chapter 2: Introduction to C++.
MATLAB Introduction MATLAB can be thought of as a powerful graphing calculator but with a lot more buttons! It is also a programming language, commands.
Unit 3: Variables in Java
Variables and Constants
Presentation transcript:

Matlab DIY Lesson 1: Reading Data

Purpose of this Seminar Basic Ability to handle Data Analysis and Presentation in Matlab Understand how data is organized Know how to read data into Matlab Know how to describe what you want to do with the data Know how to use Matlab to transform data into the form you want it in Know how to examine the output for accuracy

Syllabus Lesson 1: Reading Data In Lesson 2: Getting Data Out Lesson 3: "parsing", "batching", other manipulations of data Lesson 4: Formulas (your own and others) Lesson 5: Formulas again! Lesson 6: Plots, the basics Lesson 7:Plots, fun play with plots Lesson 8:Plots again! (graphics for publication quality) Lesson 9: Output again!

Course Materials Course Website: /index.php/Matlab_DIY_for_Beginners

Today's Lesson What does data look like? What should we be looking for? o Organization o Data Types How do we use that information? o Memory Requirements for Data o Picking the right data reading function

What does Data Look Like? What you can expect:.csv -->Comma Separated Values.tsv --> Tab Separated Values.txt --> Text data in some format Unfamiliar extension? Check the documentation --> File Extension Search

Data encoded in a CSV Trial,RT,Response,Expected 1,423,1,1 2,547,2,1 3,579,2,2 4,324,2,1 5,446,1,1

Data Encoded in a TSV Trial RT Response Expected

An example of a Data in a.txt File commas and white space were used to separate the rows and columns

Data Organization How is the data presented in the file? headers? data separators? o white space o comma o tab data types? o numbers? o letters? o mixture?

How does Matlab see data? data types? o Numbers?  Integers (whole numbers)  Doubles (decimals included) o letters?  Characters (letter)  Strings (sequences of letters) o mixture?  Characters (letter or number)  Strings (sequences of letters and numbers) o b ooleans?  True = 1  False = 0

Workspace can help you identify what Matlab sees These all look like 0 to us but Matlab sees them differently

Memory Requirements for Data How much memory do particular types require? Integers - 1,2,4, or 8 bytes (Usually 4) Doubles - 8 bytes Strings - 2 bytes per character Booleans - 8 bytes Why do we care? Program Efficiency Memory Limitations within Matlab o Limited Memory for the program o Matlab's Contiguous Memory Need

Arrays and Cells 1.In Matlab, everything is an Array 2.An Array can only store one type of data 3.Cells hold other types 4.You can make an Array of Cells 5.A Matrix is an Array of Arrays 6.A Matrix must always be square

How to use what we've learned? Matlab has multiple data parsing functions. The one to use depends on data organization. Aside from headers, is there non-numerical data? Non-Numerical data requires textscan Do you want all the data in the file? Advanced arguments to the function The above points will be explored in Lesson 3

Data type determines how Matlab reads data subj_01, male, 34, right 54301, 4578, 44478, 234 csvread textscan dlmread

First Step - Writing your first code Using the Matlab Editor Comments %This is a comment This is code Testing code in the Matlab Command Window Declaring a variable x = 1;

Opening a file from Matlab What you need: Name of the File Path to the File Filename: data.csv, collection.txt, subject117.tsv File Path: On Windows: C:\My Documents\Collection\ On Mac/Unix: /Users/default/Collection/

Declaring File Name and Path %Name of the File filename = 'L1_data.csv'; %Path to File filepath = 'C:\Desktop\Classwork\' ;

Opening that file %Name of the File filename = 'L1_data.csv'; %Path to File filepath = 'C:\Desktop\Classwork\' ; %Open the file for editing datafile = fopen([filename,filepath],'r');

Questions?

Exercises 1) Write a matlab command to open one of your own data files 2) Use Matlab help. Search for “ file formats ” to see what type of files Matlab can read and what the command is for reading them. For extra experience: 1 -- Read up on the uigetfile command in Matlab help Figure out how to use this function to get the path and name of a file.