Text Processing. Outline Announcements: –Homework I: due Today. by 5, by e-mail Discuss on Friday. –Homework II: on web HW I: question 7 Finish functions.

Slides:



Advertisements
Similar presentations
Lab # 03- SS Basic Graphic Commands. Lab Objectives: To understand M-files principle. To plot multiple plots on a single graph. To use different parameters.
Advertisements

MATLAB – A Computational Methods By Rohit Khokher Department of Computer Science, Sharda University, Greater Noida, India MATLAB – A Computational Methods.
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.
MATLAB – What is it? Computing environment / programming language Tool for manipulating matrices Many applications, you just need to get some numbers in.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 19P. 1Winter Quarter MATLAB: Script and.
Chapter 7. Even in quantitative sciences, we often encounter letters and/or words that must be processed by code You may want to write code that: Reads.
Graphics in MATLAB Week 15 – 5/5/09 Kate Musgrave
Additional Data Types: 2-D Arrays, Logical Arrays, Strings Selim Aksoy Bilkent University Department of Computer Engineering
Introduction to MATLAB
ES 100: Lecture 7 String Functions 1.Log in 2.Open MATLAB 3.Change the current directory and path to U: 4.Change the numeric display to compact (File,
Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/29/2003.
Introduction to MATLAB MECH 300H Spring Starting of MATLAB.
Additional Data Types: Strings Selim Aksoy Bilkent University Department of Computer Engineering
MATLAB Strings Selim Aksoy Bilkent University Department of Computer Engineering
Chapter 9 Above: An early computer input/output device on the IBM 7030 (STRETCH)
Extending MATLAB Write your own scripts and/or functions Scripts and functions are plain text files with extension.m (m-files) To execute commands contained.
M-files While commands can be entered directly to the command window, MATLAB also allows you to put commands in text files called M- files. M-files are.
AN ENGINEER’S GUIDE TO MATLAB
MATLAB and SimulinkLecture 11 To days Outline  Introduction  MATLAB Desktop  Basic Features  Branching Statements  Loops  Script file / Commando.
INTRO TO PROGRAMMING Chapter 2. M-files While commands can be entered directly to the command window, MATLAB also allows you to put commands in text files.
MATLAB File Management. MATLAB User File Management Matlab provides a group of commands to manage user files. For more information, type help iofun. pwd.
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
MATLAB Lecture One Monday 4 July Matlab Melvyn Sim Department of Decision Sciences NUS Business School
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
REVIEW 2 Exam History of Computers 1. CPU stands for _______________________. a. Counter productive units b. Central processing unit c. Copper.
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
GUI Input and Output Greg Reese, Ph.D Research Computing Support Group Academic Technology Services Miami University.
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (3): MATLAB Environment (Chapter 1)
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
ENGR 1320 Final Review - Programming Major Topics: – Functions and Scripts – Vector and Matrix Operations in Matlab Dot product Cross product – Plotting.
Introduction to Engineering MATLAB – 6 Script Files - 1 Agenda Script files.
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
Introduction to MATLAB Session 3 Simopekka Vänskä, THL Department of Mathematics and Statistics University of Helsinki 2011.
1 REVIEW 1 EXAM 3. Question 1 Which statement(s) is/are valid to create a string? a. x = “EGR 115” □ Valid □ Invalid b. x = ‘EGR 115’ □ Valid □ Invali.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room , Chris Hill, Room ,
Scientific Computing Introduction to Matlab Programming.
ENG College of Engineering Engineering Education Innovation Center 1 Array Accessing and Strings in MATLAB Topics Covered: 1.Array addressing. 2.
Chapter 6 Review: User Defined Functions Introduction to MATLAB 7 Engineering 161.
A first program 1. #include 2. using namespace std; 3. int main() { 4. cout
Dialog Boxes.
CSE123 Lecture 3 Files and File ManagementScripts.
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.
A simple classification problem Extract attributes Pattern Pattern recognition decision x C1 C2.
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.
Matlab Programming a logical approach. Outline Announcements: –Homework I: due Wed. by 5, by –Last day to add/drop or change credit/audit Iteration.
Input Output Garbage In, Garbage Out. Outline Announcements: –Homework III: due Today. by 5, by Discuss on Friday. –Homework IV: on web, due following.
General Computer Science for Engineers CISC 106 Lecture 12 James Atlas Computer and Information Sciences 08/03/2009.
Introduction to Matlab Patrice Koehl Department of Biological Sciences National University of Singapore
Recap Functions with No input OR No output Determining The Number of Input and Output Arguments Local Variables Global Variables Creating ToolBox of Functions.
CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING.
Extending MATLAB Write your own scripts and/or functions Scripts and functions are plain text files with extension.m (m-files) To execute commands contained.
Matlab Programming a logical approach. Outline Announcements: –Homework I: due Wed. by 5, by –Remember: text & subject –Last day to add/drop or.
Improving performance Matlab’s a pig. Outline Announcements: –Homework I: Solutions on web –Homework II: on web--due Wed. Homework I Performance Issues.
Strings Characters and Sentences 1.Overview 2.Creating Strings 3.Slicing Strings 4.Searching for substrings 1.
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
Input Output Garbage In, Garbage Out. Outline Announcements: –HWII solutions on web soon –Homework III: due Wednesday Advanced ASCII Binary Basics Cell-arrays.
“Moh’d Sami” AshhabSummer 2008University of Jordan MATLAB By (Mohammed Sami) Ashhab University of Jordan Summer 2008.
Scala File I/O. Types of files There are two kinds of files: Text files, and binary files Of course, it’s not that simple… Text files Text files are “human.
How to use MATLAB (using M-files) Double click this icon To start Matlab 6.5.
Input Output Garbage In, Garbage Out. Outline Announcements: –Homework III: due Wednesday Advanced ASCII Binary Basics Filesystem Fun.
MATLAB – More Script Files
MATLAB How to use (using M-files) Double click this icon
MATLAB How to use (using M-files) Double click this icon
String Manipulation Chapter 7 Attaway MATLAB 4E.
Text Processing.
Matlab Basic Dr. Imtiaz Hussain
Presentation transcript:

Text Processing

Outline Announcements: –Homework I: due Today. by 5, by Discuss on Friday. –Homework II: on web HW I: question 7 Finish functions Text Matlab path Survey

HW I: question 7 Lots of people having trouble –dt=0.1, t=(0:dt:21*dt)’; –N is up to you, so pick something easy

This isn’t English! Why do we need text? –Comments from functions –File names –Label plots –Interact with users –Record-based I/O

Hello World! Create strings with single quote (’) –a=‘Hello World!’ Believe it or not, characters are not doubles –a is an array of char Can display text nicely with disp(str) –if str is a matrix, each row is a new line

Working with text Concatenation--same as with other vectors –a=‘Hello’; b=‘World!’; –greetings=[a, ‘ ’,b]; –Will greetings=[a;b] work?

Number-to-String Conversions int2str & num2str convert numbers to text –int2str(2) returns ‘2’ str2num converts to numbers –str2num(‘3’)*2 returns 6

Searching for strings can search for single characters with find –str=‘Scripts are evil!’; –I=find(str==‘ ‘); % I=[8 12] search for substring ss in str with –I=findstr(ss,str) I=find(‘evil’,str); % I=[13]; –findstr(str,ss) is the same findstr always searches for small string in big string

Working with ASCII double(str) returns an array with ASCII codes –str=‘012ABCabc’ –num=double(str)=[ ] char(num) converts ASCII codes to char –char(num) returns ‘012ABCabc’

Misc. Text Functions R=input(QuestionStr) –asks user for input, returned as R –DO NOT USE IN THIS CLASS!!! –For entertainment purposes only. Function arguments are the best way to get info into your functions xlabel, ylabel, title --label plots text(x,y,str)--places string at x,y on plot S=sprintf(str, val1, val2, …)--C-like string creation –S=sprintf(‘Integer %d\nDouble %f\n’, 5, -pi); Integer 5 Double S is 1-by-27 array of char

String Summary Matlab stores strings in arrays of char (ASCII) –convert to ASCII values with double, to ASCII text with text –Convert numbers to strings with int2str, num2str, sprintf –Convert strings to numbers with str2num Search strings with find (single character) or findstr (substring)

Matlab Path Matlab maintains a list of directories where it searches for files –m-files, data files Type “path” to see Can add directories using addpath or through GUI –Ex: addpath(‘D:\Andy\mfiles’)

startup.m is a special script (the only good one!) that (if it exists) is executed as Matlab starts –Not installed-You must create it On UNIX/Mac, startup.m is in ~/matlab Windows: $MATLABROOT\toolbox\local Windows NT/2000: in matlab in Profiles directory –Ex: C:\WINNT\Profiles\andy\matlab –Can find out where profiles are found by typing getenv(‘USERPROFILE’) startup.m

Uses of startup.m –Personalize path--place addpath statements –Customize matlab –Set default directory –Set default graphics output (see 402)

Personal Opinion * Create your own m-files directory, & put m-files there –group m-files into subdirectories by topics Place addpaths in startup.m so you can always use your functions CD into data directories & work there *Above is the instructor’s opinion and does not necessarily reflect that of CIS or Cornell University

Survey You now know the basics of Matlab –The rest of the course will be spent extending and reinforcing that knowledge More Matlab or more applications? MatlabPolymorphic functions Objects beyond arrays Improving performance ApplicationsFile I/O (binary & text) Linear Systems Diff. Equations Statistics Graphics Polynomials & splines Signal processing (FFT) Optimization