ES 117. Formatted Input/Output Operations

Size: px
Start display at page:

Download "ES 117. Formatted Input/Output Operations"

Transcription

1 ES 117 Formatted Input/Output Operations

2 fpintf function writes formatted data in a user specified format to a file fid fprintf Function Format effects only the display of variables not their values through program execution fprintf(fid,format string,val1,val2,.) :the file id to which data will be written (no fid for printing on CW) format :the format string. % always marks the beginning of a format The structure of a format specifier %-12.5e Marker Modifier Field Width Precision Format Descriptor (Required) (Optional) (Optional) (Optional) (Required)

3 Common format specifier notation for fprintf Specifier Description %c Single character %d Decimal notation (signed) %e Exponential notation %E Exponential notation %f Fixed-point notation %g The more compact of %e and %f. Insignificant zeros do not print %s String of characters %u Decimal notation unsigned

4 Escape characters in Format strings symbol Description \n New line \t Horizontal tab \b backspace \\b Print an ordinary backslash (\) \ or Print an aposthrophe or single quote %% Print an ordinary percent symbol (%)

5 Example: Decimal (integer) data is displayed using %d format specifier. fprintf( %d\n,123) fprintf( %6d\n,123) fprintf( %6.4d\n,123) If a non decimal number is displayed with the %d specifier, the specifier will be ignored and the number will be displayed in exponential format fprintf( %6d\n,123.4) produces e+002

6 Example: floating point (real) data is displayed using %e, %f and %g format specifiers fprintf( %f\n,123.4) fprintf( %8.2f\n,123.4) (default is 6 chars after the decimal place) fprintf( %4.2f\n,123.4) fprintf( %10.2e\n,123.4) (6 chars wide field) 1.23e+002 fprintf( %10.2E\n,123.4) E+002 fprintf('%8.4f\n',123.4) fprintf('%8.4g\n',123.4)

7 Example: character data may be displayed with %c or %s format specifiers. fprintf( %c\n, s ) s fprintf( %s\n, string ) string fprintf( %8s\n, string ) string fprintf( %-8s\n, string ) String (left justified)

8 Data Import-Export Why is it important? Lab experiment results are: usually recorded in lab (even on paper) Put together and stored into a data file Analyzed using mathematical tools Text file (.txt) Microsoft Excel file (.xls) Binary file What do we want to export? Save everything in the workspace for post analysis. Save a selected number of results from the analysis in a text file (formatted or not)

9 Importing data Two common ways Direct input through the keyboard (using the input function) Good for individual input. Not so good for large amount of data. Use existing data stored in a file and import them into Matlab. Good for any data set size. Need to know the format of the data.

10 Different types of data files Importing data Text based files = formatted data for user usage. (.txt.dat ) Usually follows the American Standard Code for Information Interchange (ASCII) Binary files = Pre-converted data for computer usage. (.bin.mat) Software specific format = formatted data for software usage (.xls) Depending on the type of data file Different import function

11 Function load Syntax: load (filename) Importing data load filename loads all the variables from filename If filename has an extension other than.mat, load treats the file as ASCII data. If filename has no extension, load looks for file named filename or filename.mat and treats it as a binary MAT-file. test1.txt >> load test1.txt; >> whos Name Size Bytes Class test1 11x2 176 double array

12 Tips for loading data Use for loops to load entire series of files for j=1:n name1= test00'; name2=num2str(j); name3=.txt ; end NAME=[name1 name2 name3]; F=load(NAME); A(:,1)= F(:,1); A(:,j+1)= F(:,2); test001.txt test002.txt test003.txt

13 Importing data Function dlmread test2.txt 7.2;8.5;6.2; ;9.2;8.1;7.2 Syntax: A = dlmread('filename', 'delimiter'); test3.txt dlmread command works even if the contents of filename has spaces: 7.2; 8.5; 6.2; ; 9.2; 8.1; 7.2 >> A=dlmread('test2.txt',';') A =

14 Importing data Function textread Syntax: [A,B,C,...] = textread('filename','format') [A,B,C,...] = textread('filename','format',n) [A,B,C,...] = textread('filename','format') reads data from the file filename into the variables A,B,C, and so on, using the specified format, until the entire file is read. textread is useful for reading text files with known mixed formats. Both fixed and free format files can be handled. The format needs to be specified with a specifier like fprintf %s for string, %f for fix point notation %d for integers [A,B,C,...] = textread('filename','format',n) reads data from the file 'filename' N times.

15 Importing data test4.txt Ann Type Yes Joe Type No >> [A B C D E]=textread('test4.txt',' %s %s %f %f %s') A = 'Ann' 'Joe' B = 'Type1' 'Type2' C = D = E = 'Yes' 'No' >> [A B C D E]=textread('test4.txt',' %s %s %f %f %s',1) A = 'Ann' B = 'Type1' C = D = 45 E = 'Yes'

16 Importing data - Summary Data Format Sample File Extension Matlab function txt.dat or other load 1; 2; 3; 4; 5 6; 7; 8; 9; 10 or 1, 2, 3, 4, 5 6, 7, 8, 9, 10 Ann Type Yes Joe Type No Grade1 Grade2 Grade txt.dat.csv or other.txt.dat or other.txt.dat or other dlmread or csvread textread or fscanf textread or fscanf

17 Importing- Exporting data using fprintf or fscanf functions Three Steps: Functions fopen, fprintf/fscanf and fclose 1. fopen: opens a file or obtain information about open files Syntax: fid = fopen(filename,permission) Permission = 'r Open file for reading (default). 'w Open file, or create new file, for writing; discard existing contents, if any. 'a Open file, or create new file, for writing; append data to the end of the file.

18 Importing - Exporting data fopen file permissions r Open an existing file for reading only r+ Open an existing file for reading and writing w w+ a a+ Delete the contents of an existing file (or create a new file) and open it for writing only. Delete the contents of an existing file (or create a new file) and open it for reading and writing Open an existing file (or create a new file) and open it for writing only, appending to the end of file. Open an existing file (or create a new file) and open it for reading and writing, appending to the end of file.

19 Exporting data 2 fprintf: Used the same way as display function, except that this time, the formatting of the data is retained in the data file. Syntax: fprintf(fid,format,a,...) Formats the data in the real part of matrix A (and in any additional matrix arguments) under control of the specified format string, and writes it to the file associated with file identifier fid.

20 Importing data fscanf : Read formatted data from file Syntax: A = fscanf(fid, format) [A,count] = fscanf(fid, format, size) A = fscanf(fid, format) reads data from the file specified by fid, converts it according to the specified format string, and returns it in matrix A. Argument fid is an integer file identifier obtained from fopen. format is a string specifying the format of the data to be read. [A,count] = fscanf(fid, format, size) reads the amount of data specified by size, converts it according to the specified format string, and returns it along with a count of values successfully read. size is an argument that determines how much data is read. Options for size n Read at most n numbers, characters, or strings. inf Read to the end of the file. [m,n] Read at most (m*n) numbers, characters, or strings. Fill a matrix of at most m rows in column order. n can be inf, but m cannot.

21 Importing - Exporting data Functions fopen, fscanf/fprintf and fclose 3 fclose: close one or more open files Syntax: fclose(fid)

22 Exporting data Functions fopen, fprintf and fclose x = 0:0.1:1; Y = [x; exp(x)]; fid = fopen('exp.txt','w'); fprintf(fid,'%6.2f %12.8f \n',y); fclose(fid) File created in current directory Exp.txt

23 Importing data Example 1: fid = fopen('exp.txt', 'r'); a = fscanf(fid, '%f %f', [2 inf]) a = a'; fclose(fid) xdata.txt Example 2: clc;clear; fileid=fopen( xdata.txt', 'r' ); [a,nvals]=fscanf( fileid,'%d ',inf); fclose( fileid); a nvals % It has two rows now. a = nvals =

24 Importing data (more ) Function xlsread reads MS Excel files Syntax: num = xlsread(filename) num = xlsread(filename, -1) num = xlsread(filename, sheet, 'range ) num = xlsread(filename) returns numeric data in double array num from the first sheet in the Microsoft Excel spreadsheet file named filename. The filename argument is a string enclosed in single quotes. num = xlsread(filename, -1) opens the file filename in an Excel window, enabling you to interactively select the worksheet to be read and the range of data on that worksheet to import. num = xlsread(filename, sheet, 'range') reads data from a specific rectangular region (range) of the worksheet specified by sheet.

25 Importing data (more ) Example: xlsread A = xlsread('testdata1.xls') A = testdata1.xls

26 Importing data (more ) Example: xlsread A = xlsread('testdata1.xls,-1) A = testdata1.xls

27 Importing data (more ) Example: xlsread A = xlsread('testdata1.xls',1, 'A4:B5') A = testdata1.xls

28 Exporting data (more ) Function xlswrite Syntax: xlswrite(filename, M) xlswrite(filename, M, sheet, 'range') xlswrite(filename, M) writes matrix M to the Excel file filename. The filename input is a string enclosed in single quotes. The input matrix M is an m-by-n numeric, character, or cell array, where m < and n < 256. The matrix data is written to the first worksheet in the file, starting at cell A1. xlswrite(filename, M, sheet, 'range') writes matrix M to a rectangular region specified by range in worksheet sheet of the file filename.

29 Exporting data (more ) Example: xlswrite xlswrite('testdata', [ ]) d = {'Time', 'Temp'; 12 98; 13 99; 14 97}; s = xlswrite('tempdata.xls', d, 'Temperatures', 'E1') tempdata.xls Time Temp

30 The Import Wizard To import ASCII data, you must know how the data in the file is formatted. For example, many ASCII data files use a fixed (or uniform) format of rows and columns (continued )

31 The Import Wizard (continued) For these files, you should know the following. How many data items are in each row? Are the data items numeric, text strings, or a mixture of both types? Does each row or column have a descriptive text header? What character is used as the delimiter, that is, the character used to separate the data items in each row? The delimiter is also called the column separator (continued )

32 The Import Wizard (continued) You can use the Import Wizard to import many types of ASCII data formats, including data on the clipboard. When you use the Import Wizard to create a variable in the MATLAB workspace, it overwrites any existing variable in the workspace with the same name without issuing a warning. The Import Wizard presents a series of dialog boxes in which you: 1. Specify the name of the file you want to import, 2. Specify the delimiter used in the file, and 3. Select the variables that you want to import. 3-86

33

34

35

CSE 123. Lecture 9. Formatted. Input/Output Operations

CSE 123. Lecture 9. Formatted. Input/Output Operations CSE 123 Lecture 9 Formatted Input/Output Operations fpintf function writes formatted data in a user specified format to a file fid fprintf Function Format effects only the display of variables not their

More information

Using files. Computer Programming for Engineers (2014 Spring)

Using files. Computer Programming for Engineers (2014 Spring) Computer Programming for Engineers (2014 Spring) Using files Hyoungshick Kim Department of Computer Science and Engineering College of Information and Communication Engineering Sungkyunkwan University

More information

PROGRAMMING WITH MATLAB WEEK 13

PROGRAMMING WITH MATLAB WEEK 13 PROGRAMMING WITH MATLAB WEEK 13 FILE INPUT AND OUTPUT Input statements read in values from the default or standard input device. In most systems the default input device is the keyboard. The input expression

More information

Access to Delimited Text Files

Access to Delimited Text Files Access to Delimited Text Files dlmread(filename, delimiter) reads ASCII-delimited file of numeric data. dlmwrite(filename, M, delimiter) writes the array M to the file using the specified delimiter to

More information

1 >> Lecture 6 2 >> 3 >> -- User-Controlled Input and Output 4 >> Zheng-Liang Lu 367 / 400

1 >> Lecture 6 2 >> 3 >> -- User-Controlled Input and Output 4 >> Zheng-Liang Lu 367 / 400 1 >> Lecture 6 2 >> 3 >> -- User-Controlled Input and Output 4 >> Zheng-Liang Lu 367 / 400 American Standard Code for Information Interchange (ASCII) 2 Everything in the computer is encoded in binary.

More information

Singular Value Decomposition (SVD) 1

Singular Value Decomposition (SVD) 1 Singular Value Decomposition (SVD) 1 Let A m n be a matrix. Then σ is called one singular value associated with the singular vectors u R m 1 and v R n 1 for A provided that { Av = σu, A T u = σv. We further

More information

Beyond the Mouse A Short Course on Programming

Beyond the Mouse A Short Course on Programming 1 / 14 Beyond the Mouse A Short Course on Programming 5. Matlab IO: Getting data in and out of Matlab Ronni Grapenthin and Glenn Thompson Geophysical Institute, University of Alaska Fairbanks October 10,

More information

Fö 6: Filhantering. DN1212 Numeriska metoder och grundläggande programmering. Pawel Herman. KTH/CB

Fö 6: Filhantering. DN1212 Numeriska metoder och grundläggande programmering. Pawel Herman. KTH/CB Fö 6: Filhantering DN1212 Numeriska metoder och grundläggande programmering paherman@kth.se KTH/CB 22 februari Pawel 2013Herman Lecture outline Recapitulation of what we already know about I/O Matlab format

More information

Chapter 11 Input/Output (I/O) Functions

Chapter 11 Input/Output (I/O) Functions EGR115 Introduction to Computing for Engineers Input/Output (I/O) Functions from: S.J. Chapman, MATLAB Programming for Engineers, 5 th Ed. 2016 Cengage Learning Topics Introduction: MATLAB I/O 11.1 The

More information

5. MATLAB I/O 1. Beyond the Mouse GEOS 436/636 Jeff Freymueller, Sep 26, The Uncomfortable Truths Well, hop://xkcd.com/568 (April 13, 2009)

5. MATLAB I/O 1. Beyond the Mouse GEOS 436/636 Jeff Freymueller, Sep 26, The Uncomfortable Truths Well, hop://xkcd.com/568 (April 13, 2009) 5. MATLAB I/O 1 Beyond the Mouse GEOS 436/636 Jeff Freymueller, Sep 26, 2017 The Uncomfortable Truths Well, hop://xkcd.com/568 (April 13, 2009) Topics Loading and Saving the Workspace File Access Plo$ng

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

MATLAB User-defined functions, Data Input/Output. Edited by Péter Vass

MATLAB User-defined functions, Data Input/Output. Edited by Péter Vass MATLAB User-defined functions, Data Input/Output Edited by Péter Vass User-defined functions Although, MATLAB provides a wide range of built-in functions it may often be necessary to create and use an

More information

Low-Level File I/O. 1. Open a file. 2. Read or write data into the file. 3. Close the file. Zheng-Liang Lu 1 / 14

Low-Level File I/O. 1. Open a file. 2. Read or write data into the file. 3. Close the file. Zheng-Liang Lu 1 / 14 Low-Level File I/O Low-level file I/O functions allow the most control over reading or writing data to a file. However, these functions require that you specify more detailed information about your file

More information

ENG Introduction to Engineering

ENG Introduction to Engineering GoBack ENG 100 - Introduction to Engineering Lecture # 9 Files, Sounds, Images and Movies Koç University ENG 100 - Slide #1 File Handling MATLAB has two general ways of importing/exporting data from the

More information

12-Reading Data text: Chapter ECEGR 101 Engineering Problem Solving with Matlab Professor Henry Louie

12-Reading Data text: Chapter ECEGR 101 Engineering Problem Solving with Matlab Professor Henry Louie 12-Reading Data text: Chapter 4.4-4.5 ECEGR 101 Engineering Problem Solving with Matlab Professor Henry Louie Overview Reading Data from.txt Reading Data from.xls and.csv Reading Data from.mat User Interface

More information

Working with Excel Files. a = round(rand(5,3)*100) xlswrite('rand.xlsx',a) b = xlsread('rand.xlsx')

Working with Excel Files. a = round(rand(5,3)*100) xlswrite('rand.xlsx',a) b = xlsread('rand.xlsx') File I/O Working with Excel Files a = round(rand(5,3)*100) xlswrite('rand.xlsx',a) b = xlsread('rand.xlsx') Excel files with mixed content >> [nums, txt, raw] = xlsread('texttest.xls') nums = 123 333 432

More information

Lecture 7. MATLAB and Numerical Analysis (4)

Lecture 7. MATLAB and Numerical Analysis (4) Lecture 7 MATLAB and Numerical Analysis (4) Topics for the last 2 weeks (Based on your feedback) PDEs How to email results (after FFT Analysis (1D/2D) Advanced Read/Write Solve more problems Plotting3Dscatter

More information

Matlab Input/Output. Goal of this section Learn user-controlled Input Output Read/write data files (optional) Input/output 5-

Matlab Input/Output. Goal of this section Learn user-controlled Input Output Read/write data files (optional) Input/output 5- Matlab Input/Output Goal of this section Learn user-controlled Input Output Read/write data files (optional) 85-232 Input/output 5-1 Input: initialization >> a=[-1 0 0 ; 1 1 0] >> b=[1, 2, 3; 2:4] >> b=[1,

More information

Scalars and Variables

Scalars and Variables Chapter 2 Scalars and Variables In this chapter, we will discuss arithmetic operations with scalars (numbers, really an array with only one element) and variables. Scalars can be used directly in calculations

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 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

Lecture 5: Strings, Printing, and File I/O

Lecture 5: Strings, Printing, and File I/O 1 Lecture 5: Strings, Printing, and File I/O 1 Learning objectives At the of this class you should be able to... be able to name the three Matlab data types most commonly used in ME 352 be able to use

More information

MATLAB. Data and File Management

MATLAB. Data and File Management MATLAB Data and File Management File Details Storage of data in variables and arrays is temporary. For permanent retention of data files are used. All of us are familiar with files. We save our work (e.g.

More information

CMPT 102 Introduction to Scientific Computer Programming. Input and Output. Your first program

CMPT 102 Introduction to Scientific Computer Programming. Input and Output. Your first program CMPT 102 Introduction to Scientific Computer Programming Input and Output Janice Regan, CMPT 102, Sept. 2006 0 Your first program /* My first C program */ /* make the computer print the string Hello world

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

Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 18 I/O in C Standard C Library I/O commands are not included as part of the C language. Instead, they are part of the Standard C Library. A collection of functions and macros that must be implemented

More information

Chapter 9. Above: An early computer input/output device on the IBM 7030 (STRETCH)

Chapter 9. Above: An early computer input/output device on the IBM 7030 (STRETCH) Chapter 9 Above: An early computer input/output device on the IBM 7030 (STRETCH) http://computer-history.info/page4.dir/pages/ibm.7030.stretch.dir/ Io One of the moon s of Jupiter (A Galilean satellite)

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

13-Writing Data text: Chapter ECEGR 101 Engineering Problem Solving with Matlab Professor Henry Louie

13-Writing Data text: Chapter ECEGR 101 Engineering Problem Solving with Matlab Professor Henry Louie 13-Writing Data text: Chapter 4.4-4.5 ECEGR 101 Engineering Problem Solving with Matlab Professor Henry Louie Overview Writing Data to.txt Writing Data to.xls and.csv Writing Data to.mat Dr. Henry Louie

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

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

AWK - PRETTY PRINTING

AWK - PRETTY PRINTING AWK - PRETTY PRINTING http://www.tutorialspoint.com/awk/awk_pretty_printing.htm Copyright tutorialspoint.com So far we have used AWK's print and printf functions to display data on standard output. But

More information

Programming in MATLAB

Programming in MATLAB 2. Scripts, Input/Output and if Faculty of mathematics, physics and informatics Comenius University in Bratislava October 7th, 2015 Scripts Scripts script is basically just a sequence of commands the same

More information

INTRODUCTION TO C++ C FORMATTED INPUT/OUTPUT. Dept. of Electronic Engineering, NCHU. Original slides are from

INTRODUCTION TO C++ C FORMATTED INPUT/OUTPUT. Dept. of Electronic Engineering, NCHU. Original slides are from INTRODUCTION TO C++ C FORMATTED INPUT/OUTPUT Original slides are from http://sites.google.com/site/progntut/ Dept. of Electronic Engineering, NCHU Outline 2 printf and scanf Streams (input and output)

More information

Chapter 3: Functions and Files

Chapter 3: Functions and Files Topics Covered: Chapter 3: Functions and Files Built-In Functions Mathematical Functions User-Defined Functions Function Files Anonymous Functions Function Functions Function Handles Working with Data

More information

Number Systems, Scalar Types, and Input and Output

Number Systems, Scalar Types, and Input and Output Number Systems, Scalar Types, and Input and Output Outline: Binary, Octal, Hexadecimal, and Decimal Numbers Character Set Comments Declaration Data Types and Constants Integral Data Types Floating-Point

More information

Worksheet 6. Input and Output

Worksheet 6. Input and Output Worksheet 6. Input and Output Most programs (except those that run other programs) contain input or output. Both fortran and matlab can read and write binary files, but we will stick to ascii. It is worth

More information

Formulas and Functions

Formulas and Functions Conventions used in this document: Keyboard keys that must be pressed will be shown as Enter or Ctrl. Controls to be activated with the mouse will be shown as Start button > Settings > System > About.

More information

EKT 314/4 LABORATORIES SHEET

EKT 314/4 LABORATORIES SHEET EKT 314/4 LABORATORIES SHEET WEEK DAY HOUR 2 2 2 PREPARED BY: EN. MUHAMAD ASMI BIN ROMLI EN. MOHD FISOL BIN OSMAN JULY 2009 14 operations pass data to and from files. Use the VIs and functions to handle

More information

The Design of C: A Rational Reconstruction (cont.)

The Design of C: A Rational Reconstruction (cont.) The Design of C: A Rational Reconstruction (cont.) 1 Goals of this Lecture Recall from last lecture Help you learn about: The decisions that were available to the designers of C The decisions that were

More information

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved. C How to Program, 6/e 1992-2010 by Pearson Education, Inc. An important part of the solution to any problem is the presentation of the results. In this chapter, we discuss in depth the formatting features

More information

Tab-Delimited File and Compound Objects - Documents, Postcards, and Cubes. (Not Monographs)

Tab-Delimited File and Compound Objects - Documents, Postcards, and Cubes. (Not Monographs) 1" Tab-Delimited File and Compound Objects - Documents, Postcards, and Cubes (Not Monographs) See Help Sheet: Tab-Delimited File and Compound Object - Monograph Content "2" Page 4: Why use Tab-delimited

More information

Advanced C Programming Topics

Advanced C Programming Topics Introductory Medical Device Prototyping Advanced C Programming Topics, http://saliterman.umn.edu/ Department of Biomedical Engineering, University of Minnesota Operations on Bits 1. Recall there are 8

More information

Matlab I: Getting Started

Matlab I: Getting Started August 2012 Table of Contents Section 1: Introduction...3 About this Document...3 Introduction to Matlab...4 Section 2: An Overview of Matlab...5 Access to Matlab...5 Getting Started...6 The Desktop Layout...6

More information

Standard 11. Lesson 9. Introduction to C++( Up to Operators) 2. List any two benefits of learning C++?(Any two points)

Standard 11. Lesson 9. Introduction to C++( Up to Operators) 2. List any two benefits of learning C++?(Any two points) Standard 11 Lesson 9 Introduction to C++( Up to Operators) 2MARKS 1. Why C++ is called hybrid language? C++ supports both procedural and Object Oriented Programming paradigms. Thus, C++ is called as a

More information

Chapter 2. MATLAB Basis

Chapter 2. MATLAB Basis Chapter MATLAB Basis Learning Objectives:. Write simple program modules to implement single numerical methods and algorithms. Use variables, operators, and control structures to implement simple sequential

More information

C: How to Program. Week /Mar/05

C: How to Program. Week /Mar/05 1 C: How to Program Week 2 2007/Mar/05 Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers

More information

Matlab Reports. Open Day Jan 8, 2013 Yair Altman. Yair Altman

Matlab Reports. Open Day Jan 8, 2013 Yair Altman.  Yair Altman Matlab Reports Open Day Jan 8, 2013 Yair Altman http://undocumentedmatlab.com/files/openday.zip Yair Altman www.undocumentedmatlab.com 1 Reporting in Matlab Output to Command Window / console Output to

More information

Computer Programming in MATLAB

Computer Programming in MATLAB Computer Programming in MATLAB Prof. Dr. İrfan KAYMAZ Atatürk University Engineering Faculty Department of Mechanical Engineering User Defined Functions MATLAB has a number of built-in (compiled) functions,

More information

Standard File Pointers

Standard File Pointers 1 Programming in C Standard File Pointers Assigned to console unless redirected Standard input = stdin Used by scan function Can be redirected: cmd < input-file Standard output = stdout Used by printf

More information

Time: 8:30-10:00 pm (Arrive at 8:15 pm) Location What to bring:

Time: 8:30-10:00 pm (Arrive at 8:15 pm) Location What to bring: ECE 120 Midterm 1 HKN Review Session Time: 8:30-10:00 pm (Arrive at 8:15 pm) Location: Your Room on Compass What to bring: icard, pens/pencils, Cheat sheet (Handwritten) Overview of Review Binary IEEE

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

Goals of C "" The Goals of C (cont.) "" Goals of this Lecture"" The Design of C: A Rational Reconstruction"

Goals of C  The Goals of C (cont.)  Goals of this Lecture The Design of C: A Rational Reconstruction Goals of this Lecture The Design of C: A Rational Reconstruction Help you learn about: The decisions that were available to the designers of C The decisions that were made by the designers of C Why? Learning

More information

Programming and Data Structures

Programming and Data Structures Programming and Data Structures Teacher: Sudeshna Sarkar sudeshna@cse.iitkgp.ernet.in Department of Computer Science and Engineering Indian Institute of Technology Kharagpur #include int main()

More information

.. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar..

.. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar.. .. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar.. A Simple Program. simple.c: Basics of C /* CPE 101 Fall 2008 */ /* Alex Dekhtyar */ /* A simple program */ /* This is a comment!

More information

1. Introduction to Microsoft Excel

1. Introduction to Microsoft Excel 1. Introduction to Microsoft Excel A spreadsheet is an online version of an accountant's worksheet, which can automatically do most of the calculating for you. You can do budgets, analyze data, or generate

More information

The C++ Language. Output. Input and Output. Another type supplied by C++ Very complex, made up of several simple types.

The C++ Language. Output. Input and Output. Another type supplied by C++ Very complex, made up of several simple types. The C++ Language Input and Output Output! Output is information generated by a program.! Frequently sent the screen or a file.! An output stream is used to send information. Another type supplied by C++

More information

Unit 4. Input/Output Functions

Unit 4. Input/Output Functions Unit 4 Input/Output Functions Introduction to Input/Output Input refers to accepting data while output refers to presenting data. Normally the data is accepted from keyboard and is outputted onto the screen.

More information

Chapter 2 - Introduction to C Programming

Chapter 2 - Introduction to C Programming Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers 2.4 Memory Concepts 2.5 Arithmetic

More information

CSc Introduction to Computing

CSc Introduction to Computing CSc 10200 Introduction to Computing Lecture 2 Edgardo Molina Fall 2011 - City College of New York Thursday, September 1, 2011 Introduction to C++ Modular program: A program consisting of interrelated segments

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

Chapters covered for the final

Chapters covered for the final Chapters covered for the final Chapter 1 (About MATLAB) Chapter 2 (MATLAB environment) Chapter 3 (Built in Functions):3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.8, 3.9 Chapter 4 (Manipulating Arrays):4.1,4.2, 4.3

More information

SECTION 1: INTRODUCTION. ENGR 112 Introduction to Engineering Computing

SECTION 1: INTRODUCTION. ENGR 112 Introduction to Engineering Computing SECTION 1: INTRODUCTION ENGR 112 Introduction to Engineering Computing 2 Course Overview What is Programming? 3 Programming The implementation of algorithms in a particular computer programming language

More information

Chapter 3: Programming with MATLAB

Chapter 3: Programming with MATLAB Chapter 3: Programming with MATLAB Choi Hae Jin Chapter Objectives q Learning how to create well-documented M-files in the edit window and invoke them from the command window. q Understanding how script

More information

Basic Plotting. All plotting commands have similar interface: Most commonly used plotting commands include the following.

Basic Plotting. All plotting commands have similar interface: Most commonly used plotting commands include the following. 2D PLOTTING Basic Plotting All plotting commands have similar interface: y-coordinates: plot(y) x- and y-coordinates: plot(x,y) Most commonly used plotting commands include the following. plot: Draw a

More information

University of North Dakota PeopleSoft Finance Tip Sheets. Utilizing the Query Download Feature

University of North Dakota PeopleSoft Finance Tip Sheets. Utilizing the Query Download Feature There is a custom feature available in Query Viewer that allows files to be created from queries and copied to a user s PC. This feature doesn t have the same size limitations as running a query to HTML

More information

1/25/2018. ECE 220: Computer Systems & Programming. Write Output Using printf. Use Backslash to Include Special ASCII Characters

1/25/2018. ECE 220: Computer Systems & Programming. Write Output Using printf. Use Backslash to Include Special ASCII Characters University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 220: Computer Systems & Programming Review: Basic I/O in C Allowing Input from the Keyboard, Output to the Monitor

More information

211: Computer Architecture Summer 2016

211: Computer Architecture Summer 2016 211: Computer Architecture Summer 2016 Liu Liu Topic: C Programming Data Representation I/O: - (example) cprintf.c Memory: - memory address - stack / heap / constant space - basic data layout Pointer:

More information

ME 172. Lecture 2. Data Types and Modifier 3/7/2011. variables scanf() printf() Basic data types are. Modifiers. char int float double

ME 172. Lecture 2. Data Types and Modifier 3/7/2011. variables scanf() printf() Basic data types are. Modifiers. char int float double ME 172 Lecture 2 variables scanf() printf() 07/03/2011 ME 172 1 Data Types and Modifier Basic data types are char int float double Modifiers signed unsigned short Long 07/03/2011 ME 172 2 1 Data Types

More information

Python Working with files. May 4, 2017

Python Working with files. May 4, 2017 Python Working with files May 4, 2017 So far, everything we have done in Python was using in-memory operations. After closing the Python interpreter or after the script was done, all our input and output

More information

MATLAB 7 Data Import and Export

MATLAB 7 Data Import and Export MATLAB 7 Data Import and Export How to Contact The MathWorks www.mathworks.com Web comp.soft-sys.matlab Newsgroup www.mathworks.com/contact_ts.html Technical Support suggest@mathworks.com bugs@mathworks.com

More information

Lecture 2 Tao Wang 1

Lecture 2 Tao Wang 1 Lecture 2 Tao Wang 1 Objectives In this chapter, you will learn about: Modular programs Programming style Data types Arithmetic operations Variables and declaration statements Common programming errors

More information

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this

More information

SECTION 2: PROGRAMMING WITH MATLAB. MAE 4020/5020 Numerical Methods with MATLAB

SECTION 2: PROGRAMMING WITH MATLAB. MAE 4020/5020 Numerical Methods with MATLAB SECTION 2: PROGRAMMING WITH MATLAB MAE 4020/5020 Numerical Methods with MATLAB 2 Functions and M Files M Files 3 Script file so called due to.m filename extension Contains a series of MATLAB commands The

More information

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University ITC213: STRUCTURED PROGRAMMING Bhaskar Shrestha National College of Computer Studies Tribhuvan University Lecture 07: Data Input and Output Readings: Chapter 4 Input /Output Operations A program needs

More information

Exploring the Microsoft Access User Interface and Exploring Navicat and Sequel Pro, and refer to chapter 5 of The Data Journalist.

Exploring the Microsoft Access User Interface and Exploring Navicat and Sequel Pro, and refer to chapter 5 of The Data Journalist. Chapter 5 Exporting Data from Access and MySQL Skills you will learn: How to export data in text format from Microsoft Access, and from MySQL using Navicat and Sequel Pro. If you are unsure of the basics

More information

C introduction: part 1

C introduction: part 1 What is C? C is a compiled language that gives the programmer maximum control and efficiency 1. 1 https://computer.howstuffworks.com/c1.htm 2 / 26 3 / 26 Outline Basic file structure Main function Compilation

More information

There is also a more in-depth GUI called the Curve Fitting Toolbox. To run this toolbox, type the command

There is also a more in-depth GUI called the Curve Fitting Toolbox. To run this toolbox, type the command Matlab bootcamp Class 4 Written by Kyla Drushka More on curve fitting: GUIs Thanks to Anna (I think!) for showing me this. A very simple way to fit a function to your data is to use the Basic Fitting GUI.

More information

Spring 2010 Instructor: Michele Merler.

Spring 2010 Instructor: Michele Merler. Spring 2010 Instructor: Michele Merler http://www1.cs.columbia.edu/~mmerler/comsw3101-2.html Type from command line: matlab -nodisplay r command Tells MATLAB not to initialize the visual interface NOTE:

More information

Introduction to C Programming. Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan

Introduction to C Programming. Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan Introduction to C Programming Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan Outline Printing texts Adding 2 integers Comparing 2 integers C.E.,

More information

PART 2 DEVELOPING M-FILES

PART 2 DEVELOPING M-FILES PART 2 DEVELOPING M-FILES Presenter: Dr. Zalilah Sharer 2018 School of Chemical and Energy Engineering Universiti Teknologi Malaysia 17 September 2018 Topic Outcomes Week Topic Topic Outcomes 6-8 Creating

More information

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language 1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC

More information

Fundamentals of Programming

Fundamentals of Programming Fundamentals of Programming Lecture 4 Input & Output Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline printf scanf putchar getchar getch getche Input and Output in

More information

Strings and I/O functions

Strings and I/O functions Davies: Computer Vision, 5 th edition, online materials Matlab Tutorial 2 1 Strings and I/O functions 1. Introduction It is the purpose of these online documents to provide information on Matlab and its

More information

Fundamental of Programming (C)

Fundamental of Programming (C) Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi CE 43 - Fall 97 Lecture 4 Input and Output Department of Computer Engineering Outline printf

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

THE FUNDAMENTAL DATA TYPES

THE FUNDAMENTAL DATA TYPES THE FUNDAMENTAL DATA TYPES Declarations, Expressions, and Assignments Variables and constants are the objects that a prog. manipulates. All variables must be declared before they can be used. #include

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

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

UNIT IV-2. The I/O library functions can be classified into two broad categories:

UNIT IV-2. The I/O library functions can be classified into two broad categories: UNIT IV-2 6.0 INTRODUCTION Reading, processing and writing of data are the three essential functions of a computer program. Most programs take some data as input and display the processed data, often known

More information

CME 192: Introduction to Matlab

CME 192: Introduction to Matlab CME 192: Introduction to Matlab Matlab Basics Brett Naul January 15, 2015 Recap Using the command window interactively Variables: Assignment, Identifier rules, Workspace, command who and whos Setting the

More information

The following content has been imported from Legacy Help systems and is in the process of being checked for accuracy.

The following content has been imported from Legacy Help systems and is in the process of being checked for accuracy. Processor Debug Old Content - visit altium.com/documentation Modified by Admin on Nov 6, 2013 The following content has been imported from Legacy Help systems and is in the process of being checked for

More information

Excel 2016 Basics for Mac

Excel 2016 Basics for Mac Excel 2016 Basics for Mac Excel 2016 Basics for Mac Training Objective To learn the tools and features to get started using Excel 2016 more efficiently and effectively. What you can expect to learn from

More information

OUTLINES. Variable names in MATLAB. Matrices, Vectors and Scalar. Entering a vector Colon operator ( : ) Mathematical operations on vectors.

OUTLINES. Variable names in MATLAB. Matrices, Vectors and Scalar. Entering a vector Colon operator ( : ) Mathematical operations on vectors. 1 LECTURE 3 OUTLINES Variable names in MATLAB Examples Matrices, Vectors and Scalar Scalar Vectors Entering a vector Colon operator ( : ) Mathematical operations on vectors examples 2 VARIABLE NAMES IN

More information

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Parts of a C++ Program Parts of a C++ Program // sample C++ program

More information

The Design of C: A Rational Reconstruction (cont.)" Jennifer Rexford!

The Design of C: A Rational Reconstruction (cont.) Jennifer Rexford! The Design of C: A Rational Reconstruction (cont.)" Jennifer Rexford! 1 Goals of this Lecture"" Help you learn about:! The decisions that were available to the designers of C! The decisions that were made

More information

A Quick Tutorial on MATLAB. Zeeshan Ali

A Quick Tutorial on MATLAB. Zeeshan Ali A Quick Tutorial on MATLAB Zeeshan Ali MATLAB MATLAB is a software package for doing numerical computation. It was originally designed for solving linear algebra type problems using matrices. It's name

More information

Chapter 1 & 2 Introduction to C Language

Chapter 1 & 2 Introduction to C Language 1 Chapter 1 & 2 Introduction to C Language Copyright 2007 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 1 & 2 - Introduction to C Language 2 Outline 1.1 The History

More information

Introduction to Computer Applications CISY Zahoor Khan, Ph.D.

Introduction to Computer Applications CISY Zahoor Khan, Ph.D. Introduction to Computer Applications CISY 1225 Zahoor Khan, Ph.D. Last updated: May 2014 CISY 1225 Custom book Chapter 5 Introduction to Excel Copyright 2011 Pearson Education, Inc. Publishing as Prentice

More information

Formatted Output Pearson Education, Inc. All rights reserved.

Formatted Output Pearson Education, Inc. All rights reserved. 1 29 Formatted Output 2 OBJECTIVES In this chapter you will learn: To understand input and output streams. To use printf formatting. To print with field widths and precisions. To use formatting flags in

More information