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

Slides:



Advertisements
Similar presentations
CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
Advertisements

P1PMF Split1 QBASIC. P1PMF Split2QBasic Command Prompt Will launch the emulator DOS operating system? Press Alt + Enter to display the widescreen.
General Computer Science for Engineers CISC 106 Lecture 01 James Atlas Computer and Information Sciences 9/2/2009.
Chapter 8 and 9 Review: Logical Functions and Control Structures Introduction to MATLAB 7 Engineering 161.
Tutorial #7 Flowcharts (reprise) Program Design. Introduction We mentioned it already, that if we thing of an analyst as being analogous to an architect,
General Computer Science for Engineers CISC 106 Lecture 21 Dr. John Cavazos Computer and Information Sciences 04/10/2009.
General Computer Science for Engineers CISC 106 Lecture 19 Dr. John Cavazos Computer and Information Sciences 04/06/2009.
General Computer Science for Engineers CISC 106 Lecture 22 Dr. John Cavazos Computer and Information Sciences 04/13/2009.
ENGG 1801 Engineering Computing MATLAB Lecture 2: Background for Week 4 Tutorial Simple Programming in MATLAB.
General Computer Science for Engineers CISC 106 Lecture 04 Roger Craig Computer and Information Sciences 9/11/2009.
General Computer Science for Engineers CISC 106 Lecture 07 Dr. John Cavazos Computer and Information Sciences 2/25/2009.
General Computer Science for Engineers CISC 106 Lecture 20 Dr. John Cavazos Computer and Information Sciences 04/08/2009.
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.
General Computer Science for Engineers CISC 106 Lecture 10 Roger Craig Computer and Information Sciences 3/06/2009.
General Computer Science for Engineers CISC 106 Lecture 25 Dr. John Cavazos Computer and Information Sciences 04/20/2009.
General Computer Science for Engineers CISC 106 Lecture 34 Dr. John Cavazos Computer and Information Sciences 05/13/2009.
General Computer Science for Engineers CISC 106 Lecture 30 Dr. John Cavazos Computer and Information Sciences 05/04/2009.
General Computer Science for Engineers CISC 106 Lecture 33 Dr. John Cavazos Computer and Information Sciences 05/11/2009.
General Computer Science for Engineers CISC 106 Lecture 09 James Atlas Computer and Information Sciences 9/25/2009.
Precedence Parentheses Arithemetic ^ * / + - (exception logical not ~ ) Relational > =
General Computer Science for Engineers CISC 106 Lecture 23 Dr. John Cavazos Computer and Information Sciences 4/15/2009.
General Computer Science for Engineers CISC 106 Lecture 26 Dr. John Cavazos Computer and Information Sciences 04/24/2009.
Chapter 4 MATLAB Programming Logical Structures Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
General Computer Science for Engineers CISC 106 Lecture 18 Dr. John Cavazos Computer and Information Sciences 3/27/2009.
Programming with MATLAB. Relational Operators The arithmetic operators has precedence over relational operators.
Introduction to programming in MATLAB MATLAB can be thought of as an super-powerful graphing calculator Remember the TI-83 from calculus? With many more.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 21P. 1Winter Quarter MATLAB: Structures.
General Computer Science for Engineers CISC 106 Lecture 07 James Atlas Computer and Information Sciences 06/29/2009.
CS 122 Engineering Computation Lab Lab 2 Dan De Sousa and Tim Cheeseman Department of Computer Science Drexel University April 2009 ©By the author. All.
Selection Programming EE 100. Outline introduction Relational and Logical Operators Flow Control Loops Update Processes.
ENG 1181 College of Engineering Engineering Education Innovation Center MAT – Conditional Statements Topics: 1.Conditional statements if-end if-else-end.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
CMPS 1371 Introduction to Computing for Engineers MatLab.
Coding Design Tools Rachel Gauci. What are Coding Design Tools? IPO charts (Input Process Output) Input- Make a list of what data is required (this generally.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Saeed Ghanbartehrani Summer 2015 Lecture Notes #5: Programming Structures IE 212: Computational Methods for Industrial Engineering.
Intro to Nested Looping Intro to Computer Science CS1510 Dr. Sarah Diesburg.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
Chapter 8: MuPAD Programming I Conditional Control and Loops MATLAB for Scientist and Engineers Using Symbolic Toolbox.
Structured Programming II: If Statements By the end of this class you should be able to: implement branching in a program describe and use an “if” statement.
General Computer Science for Engineers CISC 106 Lecture 13 - Midterm Review James Atlas Computer and Information Sciences 10/02/2009.
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 14 James Atlas Computer and Information Sciences 08/10/2009.
General Computer Science for Engineers CISC 106 Lecture 02 James Atlas Computer and Information Sciences.
General Computer Science for Engineers CISC 106 Lecture 03 James Atlas Computer and Information Sciences 6/15/2009.
Beginning Programming for Engineers Matlab Conditional Computation.
LESSON 5 LOOPING AND BRANCHING Azalya Rahmatika Fathul Fithrah JURUSAN MATEMATIKA FAKULTAS MATEMATIKA DAN ILMU PENGETAHUAN ALAM UNIVERSITAS SYIAH KUALA.
General Computer Science for Engineers CISC 106 Lecture 27 Dr. John Cavazos Computer and Information Sciences 04/27/2009.
General Computer Science for Engineers CISC 106 Lecture 03 James Atlas Computer and Information Sciences 9/9/2009.
General Computer Science for Engineers CISC 106 Lecture 09 Dr. John Cavazos Computer and Information Sciences 03/04/2009.
Matlab Training Session 4: Control, Flow and Functions
ECE 1304 Introduction to Electrical and Computer Engineering
Chapter 4 MATLAB Programming
CS1371 Introduction to Computing for Engineers
ENGG 1801 Engineering Computing
A computer program is a sequence of computer commands.
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Control Structure Senior Lecturer
Intro to Nested Looping
Types, Truth, and Expressions (Part 2)
محاسبات عددی و برنامه نویسی
Logical Operations In Matlab.
Intro to Programming CURIE 2011.
Intro to Nested Looping
Computer Science Core Concepts
Conditional Statements
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
General Computer Science for Engineers CISC 106 Lecture 15
ME 123 Computer Applications I Lecture 11: More on For loop 3/27/03
Presentation transcript:

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

Lecture Overview How to start Matlab from the command line How to use simple command line commands for Matlab How to use For and While loops How to use If statements

Matlab from the Command Line On strauss you have access to the GUI version of matlab If you have a Mac you can access the GUI using a few simple commands On a PC accessing the GUI version of matlab takes a bit more work.... so we use matlab from the command line

Matlab from the Command Line Command line version of matlab: ssh then type matlab –nodesktop GUI version use: ssh –X then type matlab

Matlab from the Command Line Now lets try some basic commands: > 4^2 will return 16 >a=5; will show nothing, the “;” suppresses output > a will return 5

Matlab from the Command Line >clc will clear the screen >clear will clear all variables

Loops Basic loops: FOR loop and WHILE loop ◦ The FOR loop executes a set of commands a predetermined number of times with a predetermined index ◦ the WHILE loop executes a command or a set of commands until a certain predetermined condition is met

FOR Loops When you type: > for i=1:3, i end It will return: > i = 1 > i = 2 > i = 3

FOR Loops When you type: > for i=1:3 i=i*2; i=i+5 end It will return: > i = 7 > i = 9 > i = 11

FOR Loops examples Print a list of numbers forward only when greater than some number Print a list of numbers backward only when greater than some number

WHILE Loops When you type: > i = 3; > while (i >0) ‏ i i = i-1; end It will return: > i = 3; > i = 2; > i = 1;

WHILE Loops When you type: > i = 16; > while (i >1) ‏ i= i/2 end It will return > i = 8; > i = 4; > i = 2;

IF Statements IF statements allow program to make choices whether a condition is met or not Basic if statement if expression1 statements1 elseif expression2 statements2 else statements3 end

IF Statements IF statements can be used with or without the ELSEIF and ELSE parts If you type: > x = 5 > if (x == 5) ‏ 200 end It will return: > 200

IF Statements > x = 8 > if (x == 5) ‏ 200 elseif (x == 4) ‏ 300 else 400 end Will return: > 400

Putting For loops and Ifs together  for j = 1:10 if (j > 5) j end Will print what?