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,

Slides:



Advertisements
Similar presentations
Getting Input in Python Assumes assignment statement, typecasts.
Advertisements

Lecture 9: Character and String
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.
ES 314 Lecture 2 Sep 1 Summary of lecture 1: course overview intro to matlab sections of Chapters 2 and 3.
Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
Fall 2006AE6382 Design Computing1 Numeric Representation in a Computer Learning Objectives Understand how numbers are stored in a computer and how the.
CSE202: Lecture 2The Ohio State University1 Variables and C++ Data Types.
Computer Science 1620 Variables and Memory. Review Examples: write a program that calculates and displays the average of the numbers 45, 69, and 106.
1 9/10/07CS150 Introduction to Computer Science 1 Data Types Section 2.7 – 2.12 CS 150 Introduction to Computer Science I.
Mathematical Operators  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course. Introduction to Computers and Programming in.
1 9/8/08CS150 Introduction to Computer Science 1 Data Types Section 2.7 – 2.12 CS 150 Introduction to Computer Science I.
Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates.
1 Key Concepts:  Data types in C.  What is a variable?  Variable Declaration  Variable Initialization  Printf()  Scanf()  Working with numbers in.
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.
January 24, 2005 Lecture 3 - By P. Lin 1 CPET 190 Lecture 3 Problem Solving with MATLAB
MATLAB File Management. MATLAB User File Management Matlab provides a group of commands to manage user files. For more information, type help iofun. pwd.
CIS Computer Programming Logic
Slide deck by Dr. Greg Reese Miami University MATLAB An Introduction With Applications, 5 th Edition Dr. Amos Gilat The Ohio State University Chapter 4.
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Text Processing. Outline Announcements: –Homework I: due Today. by 5, by Discuss on Friday. –Homework II: on web HW I: question 7 Finish functions.
GUI Input and Output Greg Reese, Ph.D Research Computing Support Group Academic Technology Services Miami University.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #002 (January 17, 2015)
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (3): MATLAB Environment (Chapter 1)
Mastering Char to ASCII AND DOING MORE RELATED STRING MANIPULATION Why VB.Net ?  The Language resembles Pseudocode - good for teaching and learning fundamentals.
C Tokens Identifiers Keywords Constants Operators Special symbols.
Why does it matter how data is stored on a computer? Example: Perform each of the following calculations in your head. a = 4/3 b = a – 1 c = 3*b e = 1.
CS190/295 Programming in Python for Life Sciences: Lecture 3 Instructor: Xiaohui Xie University of California, Irvine.
CS151 Introduction to Digital Design
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 5 – Dental Payment Application: Introducing.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
ENGR-25_Programming-3.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical.
Array, Pointer and Reference ( I ) Ying Wu Electrical & Computer Engineering Northwestern University ECE230 Lectures Series.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
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.
1 Input / Output Input – reads/gets data for the program Output – the product, after processing Both can be: interactive I/O (while program is running)
Variables, Expressions and Statements
Getting Started with MATLAB (part2) 1. Basic Data manipulation 2. Basic Data Understanding 1. The Binary System 2. The ASCII Table 3. Creating Good Variables.
A first program 1. #include 2. using namespace std; 3. int main() { 4. cout
CS 111 – Sept. 1 Intro to data representation Binary numbers –Convert binary  decimal –Convert decimal  binary Text –ASCII and Unicode Commitment: –For.
CSE123 Lecture 3 Files and File ManagementScripts.
Lesson 4 Input. JAVA Input JAVA input is not straightforward and is different depending on the JAVA environment that you are using. The reason it is not.
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.
Chapter 2 Input, Variables and Data Types. JAVA Input JAVA input is not straightforward and is different depending on the JAVA environment that you are.
Matlab Data types, input and output. Data types Char: >> a = ‘ Jim ’ Char: >> a = ‘ Jim ’ Numeric: uint8, uint16, uint32, uint64 int8, int16, int32, int64.
Matlab Basic. MATLAB Product Family 2 3 Entering & Quitting MATLAB To enter MATLAB double click on the MATLAB icon. To Leave MATLAB Simply type quit.
Data Types and Conversions, Input from the Keyboard CS303E: Elements of Computers and Programming.
Digital Image Processing Introduction to MATLAB. Background on MATLAB (Definition) MATLAB is a high-performance language for technical computing. The.
Introduction to Engineering MATLAB – 4 Arrays Agenda Creating arrays of numbers  Vectors: 1-D Arrays  Arrays: 2-D Arrays Array Addressing Strings & String.
1 Lecture 4 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
EGR 115 Introduction to Computing for Engineers MATLAB Basics 1: Variables & Arrays Wednesday 03 Sept 2014 EGR 115 Introduction to Computing for Engineers.
1.2 Primitive Data Types and Variables
CMPS 1371 Introduction to Computing for Engineers CHARACTER STRINGS.
Data Types and Conversions, Input from the Keyboard If you can't write it down in English, you can't code it. -- Peter Halpern If you lie to the computer,
Lecture 6: More Decisions & Arrays B Burlingame 9 March 2016.
Computer science C programming language lecture 1.
Base 16 (hexadecimal) Uses the decimal digits and the first letters of the alphabet to encode 4 binary bits (16=2 4 ) abcdef or ABCDEF.
Input, Output and Variables GCSE Computer Science – Python.
How Computers Store Variables
Data Types and Conversions, Input from the Keyboard
Data Conversion & Scanner Class
EGR 115 Introduction to Computing for Engineers
Scripts & Functions Scripts and functions are contained in .m-files
Coding Schemes and Number Systems
CS 1430: Programming in C++ Turn in your Quiz1-2 No time to cover HiC.
Introduction to Programming
C++ Programming Lecture 3 C++ Basics – Part I
CS 1111 Introduction to Programming Spring 2019
MatLab Program Used to Calculate Interactive
Presentation transcript:

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, Preferences, Command Window) 5.Ask questions about homework & last lecture. 6.Take quiz when password provided.

MATLAB strings are arrays of type char: Each character is stored as two bytes, i.e., 16 bits (0’s or 1’s) >> str = 'This is a test'; >> whos Name Size Bytes Class str 1x14 28 char array Grand total is 14 elements using 28 bytes

ASCII Character Table

ASCII characters can be represented in a single byte, i.e., 8 bits (0’s or 1’s); therefore, in decimal their values range from 0 to 254 (characters beyond 127 are extended ASCII)

>> double('A')  Conversion of char to double float ans = 65  Note: The answer is returned in decimal (base 10) >> dec2bin(double('A'))  Conversion of decimal to binary ans =  Note: The red digit is not actually displayed >> 0*2^7+ 1*2^6+0*2^5+0*2^4+0*2^3+0*2^2+0*2^1+1*2^0 ans = 65  Hand conversion from binary (base 2) to decimal Some MATLAB examples of character conversion:

>> dec2hex(double('A'))  Conversion to hex ans = 41  Note: The answer is returned in base 16 >> 4*16^1+1*16^0 ans = 65  Hand conversion from hex to decimal (base 10) >> char(65)  Conversion of double float to char ans = A

>> str_array = char('Test_1 = 90','Test_2 = 100') str_array = Test_1 = 90  Concatenated strings despite size difference Test_2 = 100 >> double(str_array) ans =

>> help input INPUT Prompt for user input. R = INPUT('How many apples') gives the user the prompt in the text string and then waits for input from the keyboard. The input can be any MATLAB expression, which is evaluated, using the variables in the current workspace, and the result returned in R. If the user presses the return key without entering anything, INPUT returns an empty matrix. R = INPUT('What is your name','s') gives the prompt in the text string and waits for character string input. The typed input is not evaluated; the characters are simply returned as a MATLAB string…

Tips for homework problem 6.17: MATLAB functions have the following general form and are stored as function_name.m files in the path: % Data dictionary – displayed during help, if in path function output = function_name(input) output = valid_expressions(input); end

Tips (continued): Example string-based function % case_flip() - Flips the case of alphabetic characters % in the input string and returns this as the output string. % output_string = case_flip(input_string) function output_string = case_flip(input_string) lower_index = isstrprop(input_string,'lower'); upper_index = isstrprop(input_string,'upper'); input_string(lower_index)=upper(input_string(lower_index)); input_string(upper_index)=lower(input_string(upper_index)); output_string = input_string; end

Tips (continued): Example string-based function >> help case_flip case_flip() - flips the case of alphabetic characters in the input string and returns this as the output string. output_string = case_flip(input_string) >> case_flip('My test STRING!') ans = mY TEST string!

Do the Muddiest point, beginning with your instructor's name (not just checked). Reading assignment: Section 2.7 and Online Handout Homework: 6.12, 6.13, 6.17