General Computer Science for Engineers CISC 106 Lecture 07 Dr. John Cavazos Computer and Information Sciences 2/25/2009.

Slides:



Advertisements
Similar presentations
Introduction To MATLAB Programming
Advertisements

Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
Dale Roberts Basic I/O – printf() CSCI 230 Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Department of.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 19P. 1Winter Quarter MATLAB: Script and.
MATLAB’s extensive, device-independent plotting capabilities are one of its most powerful features. They make it very easy to plot any data at any time.
General Computer Science for Engineers CISC 106 Lecture 21 Dr. John Cavazos Computer and Information Sciences 04/10/2009.
1 Chapter 9 - Formatted Input/Output Outline 9.1Introduction 9.2Streams 9.3Formatting Output with printf 9.4Printing Integers 9.5Printing Floating-Point.
EGR 106 – Truss Design Project (cont.) Truss design programs Graphical interface tools in Matlab Saving and loading data Formatted output Project Assignment.
General Computer Science for Engineers CISC 106 Lecture 22 Dr. John Cavazos Computer and Information Sciences 04/13/2009.
General Computer Science for Engineers CISC 106 Lecture 04 Roger Craig Computer and Information Sciences 9/11/2009.
CMT Programming Software Applications
General Computer Science for Engineers CISC 106 Final Exam Review Dr. John Cavazos Computer and Information Sciences 05/18/2009.
General Computer Science for Engineers CISC 106 Lecture 08 Dr. John Cavazos Computer and Information Sciences 2/27/2009.
Introduction to Matlab Tutorial for CS4MN3/SE3X03 Wen Yu McMaster University.
Chapter 9 Formatted Input/Output Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 9 - Formatted Input/Output Outline 9.1Introduction.
Lecture 5 Input and Output inputfprintf © 2007 Daniel Valentine. All rights reserved. Published by Elsevier.
Division Example 2x - 3y + 4z = 10 x + 6y - 3z = 4 -5x + y + 2z = 3 A*X = B where A = B = >> X = A\B X =
General Computer Science for Engineers CISC 106 Lecture 09 James Atlas Computer and Information Sciences 9/25/2009.
General Computer Science for Engineers CISC 106 Lecture 05 Dr. John Cavazos Computer and Information Sciences 2/20/2009.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 6P. 1Winter Quarter I/O in C Lecture 6.
General Computer Science for Engineers CISC 106 Lecture 26 Dr. John Cavazos Computer and Information Sciences 04/24/2009.
General Computer Science for Engineers CISC 106 Lecture 18 Dr. John Cavazos Computer and Information Sciences 3/27/2009.
C Formatted Input/Output /* Using Integer Conversion Specifiers */ #include int main ( ) { printf( "%d\n", 455 ); printf( "%i\n", 455 ); printf( "%d\n",
Printing. printf: formatted printing So far we have just been copying stuff from standard-in, files, pipes, etc to the screen or another file. Say I have.
Chapter 4 MATLAB Programming Combining Loops and Logic Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
M-files While commands can be entered directly to the command window, MATLAB also allows you to put commands in text files called M- files. M-files are.
AN ENGINEER’S GUIDE TO MATLAB
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Streams Streams –Sequences of characters organized.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 9 - Formatted Input/Output Outline 9.1Introduction.
© Janice Regan, CMPT 128, Sept CMPT 128: Introduction to Computing Science for Engineering Students C++ Basic Input and output.
Chapter 9 Formatted Input/Output. Objectives In this chapter, you will learn: –To understand input and output streams. –To be able to use all print formatting.
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.
Chapter 9 Formatted Input/Output Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
 Pearson Education, Inc. All rights reserved Formatted Output.
EPSII 59:006 Spring Introduction In this lecture  Formatted Input/Output scanf and printf  Streams (input and output) gets, puts, getchar, putchar.
 2005 Pearson Education, Inc. All rights reserved Formatted Output.
Input & Output: Console
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (3): MATLAB Environment (Chapter 1)
Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
Fall 2006AE6382 Design Computing1 Control Statements in Matlab Topics IF statement and Logical Operators Switch-Case Disp() vs fprintf() Input() Statement.
CSC 107 – Programming For Science. Announcements  Memorization is not important, but…  … you will all still be responsible for information  Instead.
1 Yangon Technological University Department of Mechanical Engineering Computer Application In Mechanical Engineering I ME Dr. Yin Yin Tun Deputy.
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)
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 2/13/2009.
ENG College of Engineering Engineering Education Innovation Center 1 More Script Files in MATLAB Script File I/O : Chapter 4 1.Global Variables.
GENERATION OF RANDOM NUMBERS
EGR 115 Introduction to Computing for Engineers Formatted File Input / Output Wednesday 12 Nov 2014 EGR 115 Introduction to Computing for Engineers.
1. Overview 2. plot in 2D 3. Plot in 3D 4. Other possible charts 5. Engineers: label your plots! 6. Plots & Polynomial Plotting 11.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
1 CS1371 Introduction to Computing for Engineers Control Statements 9/4/2003.
Matlab Data types, input and output. Data types Char: >> a = ‘ Jim ’ Char: >> a = ‘ Jim ’ Numeric: uint8, uint16, uint32, uint64 int8, int16, int32, int64.
Fall 2006AE6382 Design Computing1 Control Statements in Matlab Topics IF statement and Logical Operators Switch-Case Disp() vs fprintf() Input() Statement.
Lecture 6: Output 1.Presenting results in a professional manner 2.semicolon, disp(), fprintf() 3.Placeholders 4.Special characters 5.Format-modifiers 1.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Input and Output.
1 Lecture 4 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
General Computer Science for Engineers CISC 106 Lecture 15 Dr. John Cavazos Computer and Information Sciences 03/16/2009.
General Computer Science for Engineers CISC 106 Lecture 05 James Atlas Computer and Information Sciences 6/22/2009.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 2.
Formatted I/O ä ä Standard Output ä ä printf() family of functions ä ä Standard Input ä ä scanf() family of functions.
Reading and Writing Data Files
Control Statements in Matlab
TMF1414 Introduction to Programming
Introduction to Programming for Mechanical Engineers (ME 319)
OUTPUT STATEMENTS GC 201.
Introduction to Programming - 1
ME 123 Computer Applications I Lecture 5: Input and Output 3/17/03
Presentation transcript:

General Computer Science for Engineers CISC 106 Lecture 07 Dr. John Cavazos Computer and Information Sciences 2/25/2009

Lecture Overview More Emacs Reading in and editing files Plotting Simple Plots Matlab talks back to you Using fprintf to display output.

Emacs Opening a new file emacs newfile.cpp Creates a blank file named newfile.cpp for editing If new file already exists Emacs newfile.cpp opens file for editing Save edited file by using GUI or by command Ctrl x followed by Ctrl w.

Emacs Let’s create a file with two arrays.

Plot Using the plot command plot(, ) where array1 is the x-axis and array2 is the y-axis NOTE: array1 and array2 must be equal in terms of size of dimensions!

Plot For example: x=[ ]; y=[ ]; plot(x,y)

Plot Other useful command with plot xlabel(‘ ’) – sets the label for the x-axis ylabel(‘ ’) – sets the label for the y-axis grid on – creates a grid title(‘ ’) – sets title of the plot

Matlab Output Use the fprintf command ◦ print is intuitive, but fprintf? ◦ fprintf – formatted print to a file What do files have to do with output to the screen?

Matlab Output Lets look at the syntax count = fprintf(fid, format, A,...) ◦ count – the number of bytes written ◦ fid – refers to opened file ◦ format – is a format string in between single quotes If fid is set to one or omitted the output goes to the screen.

Matlab Output Example: ◦ “There are 5 widgets in inventory” ◦ fprintf(‘There are %d widgets in inventory’, widgets); %d acts as a place holder for widget variable at end of command and is known as a conversion character. Conversion characters specify the notation of the output. Note the variable widgets as the second argument.

Matlab Output Use the fprintf command ◦ print is intuitive, but fprintf? ◦ fprintf – formatted print to a file What do files have to do with output to the screen? Lets look at the syntax count = fprintf(fid, format, A,...) ◦ count – the number of bytes written ◦ fid – refers to opened file ◦ format – is a format string If fid is set to one or omitted the output goes to the screen.

Matlab Output Example ◦ “On average we sell 2.56 widgets every 2 weeks” ◦ fprintf(‘On average we sell %f widgets every %d weeks’, widgets_ave, num_weeks); The conversion characters matter ◦ %f for fixed point notation ◦ %c for a single character‘s’ ◦ %d/%i for signed integers-2354 ◦ %s for a string of character“CISC106” ◦ Even more conversion characters online in Matlab reference.

Matlab Output Example ◦ “Line one Line two” fprintf(“Line one \nLine two”); Is the same as fprintf(“Line one”); fprintf(“\nLine Two”); Escape Characters ◦ \n – new line\t – Horizontal tab ◦ \b – backspace\\ - Backslash

Matlab Output When MATLAB gives you ugly numbers..... ◦ Take pi for example Print pi to 4 decimal places ◦ fprintf(‘Pi to 4 decimal places %.4f’, pi); ◦ Print pi to 7 significant digits ◦ fprintf(‘Pi to AT LEAST 7 significant digits %7f’, pi); ◦ Significant digits - digits before the decimal point