SUNY-New Paltz Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz “Lecture 11”

Slides:



Advertisements
Similar presentations
Introduction to File I/O How to read & write data to a disk file...
Advertisements

Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
Computer Science 121 Scientific Computing Winter 2012 Chapter 5 Files and Scripts.
Lecture 7 Debugging Code & Data Import/Export © 2007 Daniel Valentine. All rights reserved. Published by Elsevier.
Fprintf and other examples. Save command >> !ls >> a = 3; >> save afile a >> !ls afile.mat >> !dir Directory of C:\MATLAB6p5\work\save 11/21/ :30.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 19P. 1Winter Quarter MATLAB: Script and.
Nov. 28, 2005 Lecture 14 - By Paul Lin 1 CPET 190 Problem Solving with MATLAB Lecture 14 Professor Paul Lin
EGR 106 – Truss Design Project (cont.) Truss design programs Graphical interface tools in Matlab Saving and loading data Formatted output Project Assignment.
Lecture 7 Sept 17 Goals: Complete Chapter 4 Chapters 5 and 6.
Input/Output Functions Selim Aksoy Bilkent University Department of Computer Engineering
Input/Output Functions Selim Aksoy Bilkent University Department of Computer Engineering
Division Example 2x - 3y + 4z = 10 x + 6y - 3z = 4 -5x + y + 2z = 3 A*X = B where A = B = >> X = A\B X =
CIS 101: Computer Programming and Problem Solving Lecture 4 Usman Roshan Department of Computer Science NJIT.
Input/Output Functions Selim Aksoy Bilkent University Department of Computer Engineering
Fall 2006AE6382 Design Computing1 Matlab File & Directory Management Learning Objectives Define file input and output terminology Compare high and low.
The textread Function It is designed to read ASCII files that are formatted into columns of data Each column can be of a different type It is useful for.
Chapter 9 Above: An early computer input/output device on the IBM 7030 (STRETCH)
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 21P. 1Winter Quarter MATLAB: Structures.
MATLAB File Management. MATLAB User File Management Matlab provides a group of commands to manage user files. For more information, type help iofun. pwd.
SUNY-New Paltz Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz “Lecture 5”
Aloha Aloha What you see: What the computer sees: binary number columns binary number columns
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.
Lecture 06 – Reading and Writing Text Files.  At the end of this lecture, students should be able to:  Read text files  Write text files  Example.
Matlab Training Session 10: Loading Binary Data Course Website: Training Sessions.htm.
SUNY-New Paltz Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz “Lecture 6”
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
CMPS 1371 Introduction to Computing for Engineers FILE Input / Output.
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.
SUNY-New Paltz Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz “Lecture 9”
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)
1 Lab 1. C Introduction  C: –Developed by Bell lab. in –a procedure-oriented programming language.  Developing environments: –Editing –Preprocessing.
Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz SUNY-New Paltz “Lecture 2”
1 CS1371 Introduction to Computing for Engineers Introduction to Matlab.
GENERATION OF RANDOM NUMBERS
COMP 116: Introduction to Scientific Programming Lecture 29: File I/O.
EGR 115 Introduction to Computing for Engineers Formatted File Input / Output Wednesday 12 Nov 2014 EGR 115 Introduction to Computing for Engineers.
Files: By the end of this class you should be able to: Prepare for EXAM 1. create an ASCII file describe the nature of an ASCII text Use and describe string.
EGR 115 Introduction to Computing for Engineers MATLAB Basics 3: Array Operations Monday 08 Sept 2014 EGR 115 Introduction to Computing for Engineers.
SUNY-New Paltz Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz “Lecture 12”
1 Lecture 4 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
ME-2221 COMPUTER PROGRAMMING Lecture 18 FILE OPERATIONS Department of Mechanical Engineering A.H.M Fazle Elahi Khulna University of engineering & Technology.
File Access Storage of data in variables and arrays is temporary—such data is lost when a program terminates. Files are used for permanent retention of.
File Operations in Matlab Load / Save *.dat, *.mat vs. -ascii fopen /fclose.
Using and Programming with MATLAB as an Engineering Tool [ Part III ]
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
Input Output Garbage In, Garbage Out. Outline Announcements: –HWII solutions on web soon –Homework III: due Wednesday Advanced ASCII Binary Basics Cell-arrays.
Operating Systems A Biswas, Dept. of Information Technology.
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 10: Files.
Python: File Management Damian Gordon. File Management We’ve seen a range of variable types: – Integer Variables – Real Variables – Character Variables.
Input Output Garbage In, Garbage Out. Outline Announcements: –Homework III: due Wednesday Advanced ASCII Binary Basics Filesystem Fun.
Input/Output Functions. 2 MATLAB Basics: Data Files save filename var1 var2 … save homework.mat x y  binary save x.dat x – ascii  ascii load filename.
File I/O. I/O Flags Flags are passed to give some information about how the file is to be used. – Read only file – flag=0x0 – Write only file – flag=0x1.
Reading and Writing Data Files
Working with files Saving and loading Matlab variables to and from .mat files does not require any special file handling, just use save() and load() However,
MATLAB Basics Nafees Ahmed Asstt. Professor, EE Deptt DIT, DehraDun.
MATLAB Introduction Dr. Theodore Cleveland University of Houston
Functions (subprograms)
Introduction to MATLAB
Advanced Data Import & Export Jeff Henrikson
funCTIONs and Data Import/Export
Note on Indexing of Array Elements
Input/Output Functions
Using Script Files and Managing Data
Input/Output Functions
Your objective: to dominate! My objective: to help you dominate!
Electrical and Computer Engineering Department SUNY – New Paltz
Electrical and Computer Engineering Department SUNY – New Paltz
ME 123 Computer Applications I Lecture 5: Input and Output 3/17/03
Electrical and Computer Engineering Department SUNY – New Paltz
Presentation transcript:

SUNY-New Paltz Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz “Lecture 11”

SUNY-New Paltz Importing and exporting data Objectives the load and save commands; low-level file I/O functions.

SUNY-New Paltz Save Command SAVE Save workspace variables to disk SAVE FILENAME saves all variables to binary “filename.mat" SAVE FILENAME X Y Z saves X, Y, and Z SAVE... -ASCII

SUNY-New Paltz Examples A =[1 2 3 ; 4 5 6] save myData A View myData.mat with a text editor save myData -ascii

SUNY-New Paltz Load Command load myData load myData.txt A=load(‘myData.txt’)

SUNY-New Paltz Low-level file I/O functions

SUNY-New Paltz Low-level file I/O functions fid = fopen(’marks.bin’, ’w’) fwrite(fid, name) fclose(fid) fread(fid, 78, ’float’); File Handle

SUNY-New Paltz Low-level file I/O functions fid = fopen(’marks.bin’, ’w’) fwrite(fid, name) Open for Write Variable Name Pointer Update

SUNY-New Paltz Low-level file I/O functions fid = fopen(’marks.bin’, ’r’) A=fread(fid, 16, ‘float’) Open for Read Variable Size&Type Pointer Update Variable Name

SUNY-New Paltz Examples 1- Create a binary file named “odd.bin” that contains all the odd numbers between 1 and 99. Examine the file by text editor. 2- Open the binary file and read its contents into an array named OddNums. 3- Append the even numbers between 2 and 100 to the above file. Examine the file by text editor.

SUNY-New Paltz MATLAB Code fid=fopen('test1.bin','w') x=[1:2:100]; fwrite(fid,x) fclose(fid); fid=fopen('test1.bin','r') y = fread(fid) fclose(fid); fid=fopen('test1.bin','a') x=[2:2:100]; fwrite(fid,x) fclose(fid); fid=fopen('test1.bin','r') y = fread(fid) fclose(fid);

SUNY-New Paltz Example Create a text file named ‘ASCII.TXT’ that contains all the ASCII characters between 0 and 255. Use a text editor to examine the file. fid=fopen('ASCII.TXT','w') x=[1:255]; fwrite(fid,char(x)) fclose(fid);