CS 103 Test 1 Fall 2009
Enter your answers into the M-files provided. Each problem has its own M-file. Problem 1. (15 points) A. Which of the following is not an algorithm. 1. Start with 11, add each successive prime number until the sum is greater than 1
Programming Assignments
Introduction to Programming with MATLAB
Lesson 4
Unless otherwise indicated, you may assume that each function will be given the correct number of inputs
and that those inputs have the correct dimensions. For example, if the input
Lesson 6: Loops
by
Akos Ledeczi and Mike Fitzpatrick
The loop is a new control construct that makes it
possible to repeat a block of statements a
number of times.
We have already used loops without knowing it:
> n = 1:5;
> total = sum(n);
MATLAB uses loop
Lesson 5: Selection
by
Akos Ledeczi and Mike Fitzpatrick
Sequential control
Sequence of commands executed one after the other
MATLAB interpreter
Part of the MATLAB program that interprets and
executes the various commands
Sequential control: default
Co
Programming Assignments
Introduction to Programming with MATLAB
Lesson 5
Unless otherwise indicated, you may assume that each function will be given the correct number of inputs
and that those inputs have the correct dimensions. For example, if the input
Programming Assignments
Introduction to Programming with MATLAB
Lesson 3
Unless otherwise indicated, you may assume that each function will be given the correct number of inputs
and that those inputs have the correct dimensions. For example, if the input
Programming Assignments
Introduction to Programming with MATLAB
Lesson 4
Unless otherwise indicated, you may assume that each function will be given the correct number of inputs
and that those inputs have the correct dimensions. For example, if the input
Helpful Functions
MATLAB provides many hundreds of built-in functions. Here, we provide tables of some of them
that might be helpful to you in working problems for this course and later for applying what you
learn in this course1:
Table 1. Matrix-building
Lesson 4: Programmers Toolbox
by
Akos Ledeczi and Mike Fitzpatrick
Polymorphic: having multiple forms
If a function can handle calls when the same
input argument has different types:
polymorphic function
If a function can handle a variable number of
input
Programming Assignments
Introduction to Programming with MATLAB
Lesson 6
Unless otherwise indicated, you may assume that each function will be given the correct number of inputs
and that those inputs have the correct d
Lesson 7: Data Types
by
Akos Ledeczi and Mike Fitzpatrick
Real numbers in mathematics:
Can be infinitely large
Have infinitely fine resolution
Computers: Finite memory
Upper limit on the largest number that can be
represented
Lower limit on the absolu
Programming Assignments
Introduction to Programming with MATLAB
Lesson 7
Unless otherwise indicated, you may assume that each function will be given the correct number of inputs
and that those inputs have the correct dimensions. For example, if the input
Lesson 8: File Input/Output
by
Akos Ledeczi and Mike Fitzpatrick
File:
Area in permanent storage (disk drive)
Stores information
Managed by the operating system
Can be copied or moved
Can be accessed by programs
File Input/Output (I/O)
Data exchange betw
Final Programming Assignments
Introduction to Programming with MATLAB
Unless otherwise indicated, you may assume that each function will be given the correct number of inputs
and that those inputs have the correct dimensions. For example, if the input is
Programming Assignments
Introduction to Programming with MATLAB
Lesson 5
Unless otherwise indicated, you may assume that each function will be given the correct number of inputs
and that those inputs have the correct dimensions. For example, if the input
Programming Assignments
Introduction to Programming with MATLAB
Lesson 6
Unless otherwise indicated, you may assume that each function will be given the correct number of inputs
and that those inputs have the correct dimensions. For example, if the input
Programming Assignments
Introduction to Programming with MATLAB
Lesson 7
Unless otherwise indicated, you may assume that each function will be given the correct number of inputs
and that those inputs have the correct dimensions. For example, if the input
Final Programming Assignments
Introduction to Programming with MATLAB
Unless otherwise indicated, you may assume that each function will be given the correct number of inputs
and that those inputs have the correct dimensions. For example, if the input is
Lesson 3: Functions
by
Akos Ledeczi and Mike Fitzpatrick
function [out_arg1, out_arg2, .] =
function_name (in_arg1, in_arg2, .)
Examples
function
function
function
function
function
function
function
func
func(in1)
func(in1, in2)
out1 = func
out1 = func
Lesson 2: Matrices and Operators
by
Akos Ledeczi and Mike Fitzpatrick
Array
Any set of numbers arranged in a rectangular
pattern.
10
Example
A page with six rows
of four numbers each
is a two-dimensional
array
14
48
25
24
34
17
35
22
33
29
44
32
8
11
48
CS 103 Test 3 Fall 2009
Problem 1. (15 points) Enter answers to this problem into the function p1 (in the provided M-file p1.m). A. In computer programming, the word robust describes 1. a program that does something reasonable with all inputs 2. a compute
CS 103 Test 4 Fall 2009
Problem 1. (15 points) Enter answers to this problem into the function p1 (in the provided M-file p1.m). A. The break statement is used to 1. terminate a loop 2. terminate a for loop but not a while loop 3. terminate a while loop b
CS 103
Test 5
Fall 2009
Problem 1. (15 points) Enter answers to this problem into the function t5p1 (in the provided M-file t5p1.m). A. In computer science, the term stack denotes a 1. first-in-first-out data structure 2. last-in-first-out data structure
CS 103 Test 41 (the rest of Test 4) Fall 2009
Problem 1. (15 points) Enter answers to this problem into the function t4p1 (in the provided M-file t4p1.m). A. The break statement is used to 1. terminate a loop 2. terminate a for loop but not a while loop 3
CS 103
Test 6
Fall 2009
Problem 1. (15 points) Enter answers to this problem into the function t6p1 (in the provided M-file t6p1.m). A. An activation record is 1. the set of values assigned to a variable throughout a Matlab session 2. the set of locations
CS 103 Test 0 Fall 2009
Enter your answers into the M-files provided. Each problem has its own M-file. Problem 1. (15 points) A. What is the name of this course? 1. Introductory Programming for Scientists and Engineers 2. Introductory Programming for Engi
CS 103 Introductory Programming for Engineers and Scientists Spring 2015
Class Highlights
This document contains the material covered in class. It is being frequently updated, typically before
and after every cla
CS103 Spring 2014
Introductory Programming for Engineers and Scientists
EXAM 1 Solutions
Problem 1 (VERSION A):
(30 points) Write a function called arithmetic that takes two scalar inputs a and b. It needs to
return an output mul that is the product of a
DO NOT OPEN THIS EXAM UNTIL YOU ARE INSTRUCTED
SORT NUMBER:
SECTION:
CS103 Spring 2014
Introductory Programming for Engineers and Scientists
EXAM 2 VERSION A
Time Policy
You have 45 minutes to complete this exam without losing points for extra time. You m