General Computer Science for Engineers CISC 106 Lecture 15

Slides:



Advertisements
Similar presentations
Introduction to arrays
Advertisements

Computer Science & Engineering 2111 IF and Boolean Functions 1 CSE 2111 Lecture-IF and Boolean Functions.
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 28 Dr. John Cavazos Computer and Information Sciences 04/29/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 04 Roger Craig Computer and Information Sciences 9/11/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 13 Roger Craig Computer and Information Sciences 3/13/2009.
General Computer Science for Engineers CISC 106 Lecture 34 Dr. John Cavazos Computer and Information Sciences 05/13/2009.
CS 280 Data Structures Professor John Peterson. Big O Notation We use a mathematical notation called “Big O” to talk about the performance of an algorithm.
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 05 Dr. John Cavazos Computer and Information Sciences 2/20/2009.
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.
General Computer Science for Engineers CISC 106 Lecture 18 Dr. John Cavazos Computer and Information Sciences 3/27/2009.
Chapter 4 Review: Manipulating Matrices Introduction to MATLAB 7 Engineering 161.
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 2/13/2009.
Intro to Nested Looping Intro to Computer Science CS1510 Dr. Sarah Diesburg.
Matlab Programming for Engineers
Chapter 8: Arrays Copyright © 2008 W. W. Norton & Company. All rights reserved. 1 Chapter 8 Arrays.
1. Comparing Strings 2. Converting strings/numbers 3. Additional String Functions Strings Built-In Functions 1.
Intro to Loops 1.General Knowledge 2.Two Types of Loops 3.The WHILE loop 1.
Interduction to MATLAB (part 2) Manal Alotaibi Mathematics department College of science King saud university.
Chapter 2 Excel Fundamentals Logical IF (Decision) Statements Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
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 09 Dr. John Cavazos Computer and Information Sciences 03/04/2009.
Chapter 7 Matrix Mathematics
Making Choices with if Statements
L – Modeling and Simulating Social Systems with MATLAB
EGR 115 Introduction to Computing for Engineers
Chapter 4 MATLAB Programming
Visual Basic .NET BASICS
MATLAB (Lecture 2) BY:MAHA ALMOUSA.
MATH 493 Introduction to MATLAB
CNG 140 C Programming (Lecture set 8)
CSCI 3327 Visual Basic Chapter 8: Introduction to LINQ and Collections
MATLAB Basics.
Arrays Chapter 8 Copyright © 2008 W. W. Norton & Company.
Intro to Nested Looping
Introduction to MATLAB [Vectors and Matrices] Lab 2
IPC144 Introduction to Programming Using C Week 3 – Lesson 2
Chapter2 Creating Arrays
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Arrays Chapter 8 Copyright © 2008 W. W. Norton & Company.
Lecture 13: Two-Dimensional Arrays
Introduction to Matlab
Intro to Nested Looping
Loop Statements & Vectorizing Code
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.
CIS16 Application Development and Programming using Visual Basic.net
Lets Play with arrays Singh Tripty
Programming Concepts and Database
Using Script Files and Managing Data
L19. Two-Dimensional Arrays
CS 111 Introduction to Computing in Engineering and Science
Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg
Loop Statements & Vectorizing Code
USING ARRAYS IN MATLAB BUILT-IN MATH FUNCTIONS
General Computer Science for Engineers CISC 106 Lecture 03
UMBC CMSC 104 – Section 01, Fall 2016
Arrays in MatLab Arrays can have any number dimensions
Dry Run Fix it Write a program
General Computer Science for Engineers CISC 106 Lecture 11
CS 1111 Introduction to Programming Spring 2019
MATLAB (Lecture 2) BY:MAHA ALMOUSA.
Electrical and Computer Engineering Department SUNY – New Paltz
Presentation transcript:

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

Lecture Overview User Inputs Arrays and subarrays Nested Loops

User Input Input function displays a prompt waits for the user to respond value = input(‘Enter an input value:’) Enter an input value: 1.25 Value = 1.2500

User Input Input function displays a prompt waits for the user to respond name = input(‘What is your name’, ‘s’) What is your name: Pinar name= Pinar

Arrays Each dimension must have same length a = [2 3 4; 5 6 7] error!

Initialize using built-in functions x=zeros(2) x = 0 0 0 0 x = zeros(2,3) x = 0 0 0 0 0 0

Subarrays It will help with problem 4 (magic squares) on the lab Although you do not need it, it could make life easier

isMagicSquare.m Problem 4 of the lab Boolean function is a logical function Returns true or false Extra credit for that problem Check that number in the matrix is different as well http://www.udel.edu/CIS/106/cavazos/09S /labs/lab5questions.html

Subarrays It is possible to select and use subsets of MATLAB arrays. arr1(3) is 3.3 arr1([1 4]) is the array [1.1 -4.4] arr1(1 : 2 : 5) is the array [1.1 3.3 5.5]

Subarrays For 2-dimensional arrays, colon can be used . 1 2 3 arr2(:,1:2:3) 1 3 -2 -4 3 5

Subarrays end function: returns highest value taken on by that subscript arr3 = [1 2 3 4 5 6 7 8] arr3(5:end) is array [5 6 7 8]

Subarrays arr4=[1 2 3 4; 5 6 7 8; 9 10 11 12]; 1 2 3 4 5 6 7 8 9 10 11 12 arr4=(2:3, 2:4); 6 7 8 10 11 12

Subarrays arr4=[1 2 3 4; 5 6 7 8; 9 10 11 12]; arr4(1:2,1:2) = 1 1 1 3 4 1 1 7 8 9 10 11 12

Loop calculations a = [ 3 40 1 8 0]; b = [-7 5 -4 16 1]; for i = 1:5 c(i) = a(i) + b(i); c = [-4 45 -3 24 1];

for i=1:3 for j=1:4 arr4(i,j) end Doubly-nested loop

Another nested for loop for i=1:5 for j=1:5 a(i,j)=10*i+j; end