Access to Delimited Text Files
|
|
- Samson Anderson
- 6 years ago
- Views:
Transcription
1 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 separate array elements. The default delimiter is the comma (,). dlmwrite(filename, M, -append ) appends the data to the end of the existing file. dlmread(filename, delimiter, R, C) reads data whose upper left corner is at row R and column C in the file. R and C start from 0. (R, C) = (0, 0) specifies the first value in the file. Zheng-Liang Lu 377 / 403
2 Example 1 >> M = gallery('integerdata', 100, [5 8], 0); 2 >> dlmwrite('myfile.txt', M, 'delimiter', '\t'); 1 >> dlmread('myfile.txt', 't') 2 >> dlmread('myfile.txt', '\t', 2, 3) Zheng-Liang Lu 378 / 403
3 textread textread is useful for reading text files with a known format. [A, B, C,...] =textread(filename, format, N) reads data from the file filename into the variables A, B, C, and so on, using the specified format, format for N lines. format determines the number and types of return arguments. (See next page.) If you drop N, then textread reads until the end of file. The common conversions are as follows: %d: as signed integer values. %f: as floating-point values. %s: as a white-space or delimiter-separated string. Zheng-Liang Lu 379 / 403
4 Example Create a mydata.dat with the following content: 1 Sally Level Yes 2 Arthur Level No 1 >> [names, types, x, y, answer] = textread('mydata.dat',... '%s %s %f %d %s') % normal usage 1 >> [names, types, x, answer] = textread('mydata.dat',... '%s Level%d %f %*d %s', 1) % check the difference! In %*f, * ignores the matching characters specified by *. Zheng-Liang Lu 380 / 403
5 Access to Excel Files xlsread(filename, sheet, xlrange) reads from the specified sheet and range. sheet can be the sheet name 1 or a sheet number in the excel file. xlrange is optional for the rectangular portion of the worksheet to read. For example, xlrange = B:B is used to import column B. To read a single value, use xlrange = B1:B1. 2 xlswrite(filename, A, sheet, xlrange) writes the array A to the specified range of the sheet. 1 The default sheet name is 工作表 1. 2 Contribution by Mr. Tsung-Yu Hsieh (MAT24409) on August 27, Zheng-Liang Lu 381 / 403
6 Example 1 >> values = {1, 2, 3; 4, 5, 'x'; 7, 8, 9}; 2 >> headers = {'First', 'Second', 'Third'}; 3 >> xlswrite('myexample.xlsx', [headers; values]); % write 1 >> subseta = xlsread('myexample.xlsx', 1, 'B2 : C3') % read 2 3 subseta = NaN Zheng-Liang Lu 382 / 403
7 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 than the easier-to-use high-level functions, such as importdata. If the high-level functions cannot import your data, you may consider to use low-level file I/O. The normal procedure looks like: 1 Open a file. 2 Read or write data into the file. 3 Close the file. Zheng-Liang Lu 383 / 403
8 Open Files fid = fopen(filename, permission) opens the file, filename, for binary read access, and returns an integer as fid equal to or greater than 3. fid refers to the file identifier. permission: file access type, specified as a string. MATLAB reserves fids 1 and 2 for standard output on the screen and standard error, respectively. (You will see later.) If fopen fails to open the file with r, then fid is 1. You can fopen a new file with permission w. Be aware that you can repeatedly open a new file with the same file name. Zheng-Liang Lu 384 / 403
9 fopen Permission Codes r is to open file for reading. r+ additionally for writing. w is to open or create new file for writing. 3 w+ additionally for reading. a is to open or create new file for writing. Also, it appends data to the end of the file. a+ additionally for reading. 3 Be aware that it will discard existing contents, if any. Zheng-Liang Lu 385 / 403
10 Common Commands in Low-Level File I/O feof(fid), which refers to end-of-file, returns 1 if a previous operation set the end-of-file indicator for the specified file. fgetl(fid) returns the next line of the specified file, removing the newline characters. If the line contains only the end-of-file marker, then the return value is 1. Zheng-Liang Lu 386 / 403
11 Example Write a script to show the content of a text file, say, fgetl.m. 1 clear; clc 2 3 f = fopen('fgetl.m', 'r'); 4 while ~feof(f) 5 disp(fgetl(f)); 6 end 7 fclose(f); Zheng-Liang Lu 387 / 403
12 Close Files fclose(fid) closes an opened file. fclose( all ) closes all opened files. fclose returns a status of 0 when the close operation is successful. Otherwise, it returns 1. Zheng-Liang Lu 388 / 403
13 fprintf Recall that fprintf(format, A 1,..., A n ) formats data and displays the results on the screen 4. fprintf(fid, format, A 1,..., A n ) applies the format to all elements of arrays A 1,..., A n in column order, and writes the data to a text file. format: to specify a format for the output fields; it is a string. A 1,..., A n : arrays for the output fields. Matlab reserves the file identifier number 1 and 2 for standard output on the screen, and standard error, respectively. fprintf(1, This is standard output!\n ); fprintf(2, This is standard error!\n ); sprintf(format, A 1,..., A n ), similar to fprintf but returns the results as a string. 4 Recall disp. Zheng-Liang Lu 389 / 403
14 Example fprintf can print multiple numeric values and literal text to the screen. 1 >> A = [ ; ]; 2 >> format = 'X is %4.2f meters or %8.3f mm.\n'; 3 >> fprintf(format, A); % print on the screen 4 5 X is 9.90 meters or mm. 6 X is 8.80 meters or mm. 7 X is 7.70 meters or mm. %4.2f specifies that the first value in each line of output is a floating-point number with a field width of four digits, including two digits after the decimal point. Can you explain %8.3f? Zheng-Liang Lu 390 / 403
15 Escape Characters %%: Percent character \\: Backslash \b: Backspace \n: New line \t: Horizontal tab Zheng-Liang Lu 391 / 403
16 format Integer, signed: %d or %i Integer, unsigned %u: Base 10 %o: Base 8 %x: Base 16 Floating-point number 5 %f: Fixed-point notation %e: Exponential notation, such as e+00 Characters %c: Single character %s: String Note that the % can be followed by an optional field width to handle fixed width fields. 5 See IEEE 754. Zheng-Liang Lu 392 / 403
17 Example: grep in UNIX/Linux-like Systems findstr(s 1, S 2 ) returns the starting indices of any occurrences of the shorter of the two strings in the longer. 1 function grep(f, pattern) 2 f = fopen(f, 'r'); 3 cnt = 0; 4 while ~feof(f) 5 t = fgetl(f); 6 cnt = cnt + 1; 7 w = findstr(t, pattern); 8 if ~isempty(w) 9 fprintf('%d: %s\n', cnt, t); 10 end 11 end 12 fclose(f); 13 end Zheng-Liang Lu 393 / 403
18 Exercise Write a program which produces a multiplication table into a text file Zheng-Liang Lu 394 / 403
19 1 clear; clc; 2 3 f = fopen('multiplicationtable.txt', 'w'); 4 for i = 1 : 9 5 for j = 1 : 9 6 fprintf(f, '%3d', i * j); 7 end 8 fprintf(f, '\n'); 9 end 10 fclose(f); Zheng-Liang Lu 395 / 403
20 fscanf A = fscanf(fid, format, size) reads data from the file specified by file identifier fid, converts it according to the specified format string, and returns it in matrix A. fscanf populates A in column order. fscanf can be used to skip specific characters in a sample file, and return only numeric data. Zheng-Liang Lu 396 / 403
21 Example 1 clear all; 2 clc 3 str = { 4 ['78' char(176) 'C']; 5 ['72' char(176) 'C']; 6 ['64' char(176) 'C']; 7 ['66' char(176) 'C']; 8 ['49' char(176) 'C']}; 9 % char(176) is the symbol of degree 10 fid = fopen('temperature.txt', 'w'); 11 for i = 1 : length(str) 12 fprintf(fid, '%s\n', str{i}); 13 end 14 fclose(fid); 15 % main 16 fid = fopen('temperature.txt', 'r'); 17 [A, count] = fscanf(fid, ['%d' char(176) 'C']) 18 fclose(fid); Zheng-Liang Lu 397 / 403
22 1 >> 2 3 A = count = Zheng-Liang Lu 398 / 403
23 Binary Files fread(fid, size, precision) interprets values in the file according to the form and size described by precision. fwrite(fid, A, precision) translates the values of A according to the form and size described by precision. Zheng-Liang Lu 399 / 403
24 Valid entries for size are: N: read N elements into a column vector. inf : read to the end of the file. [M, N]: read elements to fill an M-by-N matrix, in column order. Valid entries for precision are: uchar : unsigned integer, 8 bits. int64 : integer, 64 bits. uint64 : unsigned integer, 64 bits. float64 : floating point, 64 bits. Note that 64 can be replaced by 8, 16, and 32. Zheng-Liang Lu 400 / 403
25 Example Create a binary file containing a 3-by-3 magic square, whose element is stored as 4-byte integers. 1 clear all; 2 clc 3 % main 4 A=magic(3) 5 fid = fopen('magic3.txt', 'w'); 6 fwrite(fid, A, 'int32'); 7 fclose(fid); 8 fid = fopen('magic3.txt', 'r'); 9 fread(fid, [3 3], 'int32'); % try [3 1]? Zheng-Liang Lu 401 / 403
26 Access to Internet urlread(url, Name, Value) returns the contents of a URL as a string. 1 contents =... urlread(' 2 f = fopen('matlab.html', 'w'); 3 fprintf(fid, '%s', contents); 4 fclose all; 5 dos('start matlab.html'); Try sendmail, ftp. Zheng-Liang Lu 402 / 403
27 Yahoo Finance API Current market and historical data from the Yahoo! data server Blog: 研究雅虎股票 API (Yahoo finance stock API) Google: yahoo-finance-managed Historical Stock Data downloader by Josiah Renfree (2008) Zheng-Liang Lu 403 / 403
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 informationSingular 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 informationLow-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 informationCSE 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 informationES 117. Formatted Input/Output Operations
ES 117 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 values through
More informationFö 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 informationPROGRAMMING 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 informationChapter 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 informationUsing 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 informationCommon Commands in Low-Level File I/O
Common Commands in Low-Level File I/O feof(fid), which refers to end-of-file, returns 1 if a previous operation set the end-of-file indicator for the specified file. tline = fgetl(fid) returns the next
More informationBeyond 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 informationLecture 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 informationWorking 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 informationImporting 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 information13-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 information12-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 information5. 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 informationLecture 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 informationMATLAB 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 informationMatlab 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 informationENG 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 informationMATLAB 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 informationScalars 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 informationCMPT 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 informationMatlab. Carlo Tomasi. Since images are matrices of numbers, many vision algorithms are naturally implemented
Matlab Carlo Tomasi MATLAB is a simple and useful high-level language for matrix manipulation. It is often convenient to use MATLAB even for programs for which this language is not the ideal choice in
More informationCopyright 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 informationC 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 informationProgramming 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 informationMATLAB. 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 informationAdvanced 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 informationWorksheet 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 information211: 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 informationFiles and Streams Opening and Closing a File Reading/Writing Text Reading/Writing Raw Data Random Access Files. C File Processing CS 2060
CS 2060 Files and Streams Files are used for long-term storage of data (on a hard drive rather than in memory). Files and Streams Files are used for long-term storage of data (on a hard drive rather than
More informationPython 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 informationUnit 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 informationQuick MATLAB Syntax Guide
Quick MATLAB Syntax Guide Some useful things, not everything if-statement Structure: if (a = = = ~=
More informationUsing 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 informationChapter 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 informationITC213: 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 informationIntroduction to Matlab
Introduction to Matlab 1 Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display Facilities Flow Control Using of M-File Writing User
More informationFile IO and command line input CSE 2451
File IO and command line input CSE 2451 File functions Open/Close files fopen() open a stream for a file fclose() closes a stream One character at a time: fgetc() similar to getchar() fputc() similar to
More informationChapters 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 information12 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 informationStrings 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 informationChapter 3: Introduction to MATLAB Programming (4 th ed.)
Chapter 3: Introduction to MATLAB Programming (4 th ed.) Algorithms MATLAB scripts Input / Output o disp versus fprintf Graphs Read and write variables (.mat files) User-defined Functions o Definition
More informationReading lines from text files
Overview Lecture 20: String Processing Reading lines from text files Processing strings Breaking a string into tokens Comparing strings for equality Converting strings to numerals Reading lines from text
More information1/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 informationNumber 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 informationAn 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 informationSpring 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 informationInput / Output Functions
CSE 2421: Systems I Low-Level Programming and Computer Organization Input / Output Functions Presentation G Read/Study: Reek Chapter 15 Gojko Babić 10-03-2018 Input and Output Functions The stdio.h contain
More informationGabriel Hugh Elkaim Spring CMPE 013/L: C Programming. CMPE 013/L: C Programming
1 Literal Constants Definition A literal or a literal constant is a value, such as a number, character or string, which may be assigned to a variable or a constant. It may also be used directly as a function
More informationLanguage Reference Manual
TAPE: A File Handling Language Language Reference Manual Tianhua Fang (tf2377) Alexander Sato (as4628) Priscilla Wang (pyw2102) Edwin Chan (cc3919) Programming Languages and Translators COMSW 4115 Fall
More informationComputers Programming Course 5. Iulian Năstac
Computers Programming Course 5 Iulian Năstac Recap from previous course Classification of the programming languages High level (Ada, Pascal, Fortran, etc.) programming languages with strong abstraction
More informationSECTION 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 informationTime: 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 informationChapter 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 informationMatlab course at. P. Ciuciu 1,2. 1: CEA/NeuroSpin/LNAO 2: IFR49
Matlab course at NeuroSpin P. Ciuciu 1,2 philippe.ciuciu@cea.fr www.lnao.fr 1: CEA/NeuroSpin/LNAO 2: IFR49 Mar 5, 2009 Outline 2/9 Lesson0: Getting started: environment,.m and.mat files Lesson I: Scalar,
More informationThe 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 informationInteractive MATLAB use. Often, many steps are needed. Automated data processing is common in Earth science! only good if problem is simple
Chapter 2 Interactive MATLAB use only good if problem is simple Often, many steps are needed We also want to be able to automate repeated tasks Automated data processing is common in Earth science! Automated
More informationUser Commands sed ( 1 )
NAME sed stream editor SYNOPSIS /usr/bin/sed [-n] script [file...] /usr/bin/sed [-n] [-e script]... [-f script_file]... [file...] /usr/xpg4/bin/sed [-n] script [file...] /usr/xpg4/bin/sed [-n] [-e script]...
More informationSECTION 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 informationFile Handling in C. EECS 2031 Fall October 27, 2014
File Handling in C EECS 2031 Fall 2014 October 27, 2014 1 Reading from and writing to files in C l stdio.h contains several functions that allow us to read from and write to files l Their names typically
More informationSTAT 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 informationIntroduction to MATLAB Programming. Chapter 3. Linguaggio Programmazione Matlab-Simulink (2017/2018)
Introduction to MATLAB Programming Chapter 3 Linguaggio Programmazione Matlab-Simulink (2017/2018) Algorithms An algorithm is the sequence of steps needed to solve a problem Top-down design approach to
More informationMICROSOFT EXCEL BIS 202. Lesson 1. Prepared By: Amna Alshurooqi Hajar Alshurooqi
MICROSOFT EXCEL Prepared By: Amna Alshurooqi Hajar Alshurooqi Lesson 1 BIS 202 1. INTRODUCTION Microsoft Excel is a spreadsheet application used to perform financial calculations, statistical analysis,
More informationINTRODUCTION 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 informationGoals 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 informationInput/Output: Advanced Concepts
Input/Output: Advanced Concepts CSE 130: Introduction to Programming in C Stony Brook University Related reading: Kelley/Pohl 1.9, 11.1 11.7 Output Formatting Review Recall that printf() employs a control
More informationMatlab 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 informationCOMP1730/COMP6730 Programming for Scientists. Data: Values, types and expressions.
COMP1730/COMP6730 Programming for Scientists Data: Values, types and expressions. Lecture outline * Data and data types. * Expressions: computing values. * Variables: remembering values. What is data?
More informationVariables and Literals
C++ By 4 EXAMPLE Variables and Literals Garbage in, garbage out! To understand data processing with C++, you must understand how C++ creates, stores, and manipulates data. This chapter teaches you how
More informationStandard 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 informationDECLARATIONS. Character Set, Keywords, Identifiers, Constants, Variables. Designed by Parul Khurana, LIECA.
DECLARATIONS Character Set, Keywords, Identifiers, Constants, Variables Character Set C uses the uppercase letters A to Z. C uses the lowercase letters a to z. C uses digits 0 to 9. C uses certain Special
More informationC mini reference. 5 Binary numbers 12
C mini reference Contents 1 Input/Output: stdio.h 2 1.1 int printf ( const char * format,... );......................... 2 1.2 int scanf ( const char * format,... );.......................... 2 1.3 char
More informationNumerical Analysis First Term Dr. Selcuk CANKURT
ISHIK UNIVERSITY FACULTY OF ENGINEERING and DEPARTMENT OF COMPUTER ENGINEERING Numerical Analysis 2017-2018 First Term Dr. Selcuk CANKURT selcuk.cankurt@ishik.edu.iq Textbook Main Textbook MATLAB for Engineers,
More informationIntroduction to MATLAB Programming
Spring 2019 Spring 2019 1 / 17 Introduction Algorithm An algorithm is a sequence of steps needed to solve a problem. We will use MATLAB to develop algorithms to solve specific problems. The basic algorithm
More informationIntermediate Programming, Spring 2017*
600.120 Intermediate Programming, Spring 2017* Misha Kazhdan *Much of the code in these examples is not commented because it would otherwise not fit on the slides. This is bad coding practice in general
More informationCOMP2611: Computer Organization. Data Representation
COMP2611: Computer Organization Comp2611 Fall 2015 2 1. Binary numbers and 2 s Complement Numbers 3 Bits: are the basis for binary number representation in digital computers What you will learn here: How
More informationC++ Basics. Lecture 2 COP 3014 Spring January 8, 2018
C++ Basics Lecture 2 COP 3014 Spring 2018 January 8, 2018 Structure of a C++ Program Sequence of statements, typically grouped into functions. function: a subprogram. a section of a program performing
More informationL4X v2.0 Reference. (v December 2008) David Fowle
L4X v2.0 Reference (v2.0.0.4-01 December 2008) http://www.pdfing.com/l4x 2 L4X v2.0 Reference Table of Contents Foreword Part I L4X Language Summary. 1 1 Importing... Strings of Text. 1 2 Importing...
More informationCME 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 informationIntroduction to Computing Lecture 03: Basic input / output operations
Introduction to Computing Lecture 03: Basic input / output operations Assist.Prof.Dr. Nükhet ÖZBEK Ege University Department of Electrical & Electronics Engineering nukhet.ozbek@ege.edu.tr Topics Streams
More informationPrinceton University. Computer Science 217: Introduction to Programming Systems. Data Types in C
Princeton University Computer Science 217: Introduction to Programming Systems Data Types in C 1 Goals of C Designers wanted C to: Support system programming Be low-level Be easy for people to handle But
More informationMATLAB Part 1. Introduction
MATLAB Part 1 Introduction MATLAB is problem solving environment which provides engineers and scientists an easy-to-use platform for a wide range of computational problems. In general, it is useful for
More informationCSCE C. Lab 10 - File I/O. Dr. Chris Bourke
CSCE 155 - C Lab 10 - File I/O Dr. Chris Bourke Prior to Lab Before attending this lab: 1. Read and familiarize yourself with this handout. 2. Review the following free textbook resources: http://en.wikibooks.org/wiki/c_programming/file_io
More informationChapter 2, Part I Introduction to C Programming
Chapter 2, Part I Introduction to C Programming C How to Program, 8/e, GE 2016 Pearson Education, Ltd. All rights reserved. 1 2016 Pearson Education, Ltd. All rights reserved. 2 2016 Pearson Education,
More informationC Concepts - I/O. Lecture 19 COP 3014 Fall November 29, 2017
C Concepts - I/O Lecture 19 COP 3014 Fall 2017 November 29, 2017 C vs. C++: Some important differences C has been around since around 1970 (or before) C++ was based on the C language While C is not actually
More informationCPE 101, reusing/mod slides from a UW course (used by permission) Lecture 5: Input and Output (I/O)
CPE 101, reusing/mod slides from a UW course (used by permission) Lecture 5: Input and Output (I/O) Overview (5) Topics Output: printf Input: scanf Basic format codes More on initializing variables 2000
More informationProgramming 1. Script files. help cd Example:
Programming Until now we worked with Matlab interactively, executing simple statements line by line, often reentering the same sequences of commands. Alternatively, we can store the Matlab input commands
More informationAnalysis Methods in Atmospheric and Oceanic Science AOSC 652. Introduction to MATLAB. Week 8, Day Oct 2014
Analysis Methods in Atmospheric and Oceanic Science 1 AOSC 652 Introduction to MATLAB Week 8, Day 1 20 Oct 2014 2 Introduction to MATLAB Matlab stands for MATrix LABoratory. Developed by http://www.mathworks.com/
More informationStandard C Library Functions
Demo lecture slides Although I will not usually give slides for demo lectures, the first two demo lectures involve practice with things which you should really know from G51PRG Since I covered much of
More informationProgramming for Engineers Introduction to C
Programming for Engineers Introduction to C ICEN 200 Spring 2018 Prof. Dola Saha 1 Simple Program 2 Comments // Fig. 2.1: fig02_01.c // A first program in C begin with //, indicating that these two lines
More informationTCL - STRINGS. Boolean value can be represented as 1, yes or true for true and 0, no, or false for false.
http://www.tutorialspoint.com/tcl-tk/tcl_strings.htm TCL - STRINGS Copyright tutorialspoint.com The primitive data-type of Tcl is string and often we can find quotes on Tcl as string only language. These
More informationIntroduction to Computer Programming in Python Dr. William C. Bulko. Data Types
Introduction to Computer Programming in Python Dr William C Bulko Data Types 2017 What is a data type? A data type is the kind of value represented by a constant or stored by a variable So far, you have
More informationGetting started with Java
Getting started with Java Magic Lines public class MagicLines { public static void main(string[] args) { } } Comments Comments are lines in your code that get ignored during execution. Good for leaving
More informationProgramming in C++ 4. The lexical basis of C++
Programming in C++ 4. The lexical basis of C++! Characters and tokens! Permissible characters! Comments & white spaces! Identifiers! Keywords! Constants! Operators! Summary 1 Characters and tokens A C++
More information3. Except for strings, double quotes, identifiers, and keywords, C++ ignores all white space.
Chapter 2: Problem Solving Using C++ TRUE/FALSE 1. Modular programs are easier to develop, correct, and modify than programs constructed in some other manner. ANS: T PTS: 1 REF: 45 2. One important requirement
More informationIntroduction to file management
1 Introduction to file management Some application require input to be taken from a file and output is required to be stored in a file. The C language provides the facility of file input-output operations.
More informationEP375 Computational Physics
EP375 Computational Physics Topic 1 MATLAB TUTORIAL BASICS Department of Engineering Physics University of Gaziantep Feb 2014 Sayfa 1 Basic Commands help command get help for a command clear all clears
More information