1
Lab 3: Files and while loops
September 23rd & 24th, 2010
Objectives:
To become familiar with writing to and reading from files
To become familiar with using simple while loops
Part 1: Reading from a file:
1. Download the file called data.dat which is in
Lab 12: We Heart Matlab!
Thurs., Fri., Dec. 1, 2
In this lab, we are going to practice accessing matrices and performing matrix operations.
We will also practice comparing vectors, printing information to screen and to file, and
go through some of the dif
Lab 11: We Heart Matlab!
Mon., Tues., Wed., Fri. Nov. 30, Dec. 1, 2, 4
In this lab, we are going to practice accessing matrices and performing matrix operations.
We will also practice comparing vectors, printing information to screen and to file, and
go t
Lab 13: More Matlab
Engineering 101; Dec 9, 10
Task 1: C+ to Matlab
Convert the following C+ code into Matlab in a script file called task1.m:
int labNumber = 0;
bool lastLab = false;
while(!lastLab) cfw_
if(labNumber = 13) cfw_
lastLab = true;
cout < goo
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
int main() cfw_
ofstream outfile("graph.txt");
int i, j;
for (i = 10; i >= 0; i = i - 1) cfw_
for (j = 0; j <= 20; j+) cfw_
if (i > 5) cfw_
if (j = i*2-10) | (j = 20 - (i
#include <iostream>
#include <fstream>
#include cmath
using namespace std;
int main() cfw_
ofstream outfile("graph.txt");
int i;
for (i = 10; i >= 0; i = i - 1) cfw_
for (j = 0; j <= 20; j+) cfw_
if (i > 5) cfw_
if (j = i*2-10) | (j = 20 - (i*2-10
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include "sort.h"
using namespace std;
/* REQUIRED FUNCTIONS */
/* This procedure will sort the values of the three input vectors depending on
* the last two arguments using inser
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <vector>
#include <cassert>
#include "sort.h"
using namespace std;
/* Returns a char for the numeral representation of r, which must be a
* single-digit integer (i.e. 0
%This function takes an image and runs a moving average filter of with a
%window size of windowLength*windowLength, where windowLength is an odd
%integer >= 1. The function will average all the elements in the window and
%enter a new value in the center p
% This function flips the image along the vertical axis, essentially giving
% the effect of it being a 'mirror image'.
function filteredImage = mirrorFilter(inputImage)
imageSize = size(inputImage);
filteredImage = zeros(imageSize);
for i = 1:ima
% This function is a simple edge detection filter where the filter
% traverses the image matrix and compares the each value to the value to
% the right and the value below it. if the absolute value of the difference
% between the two values are greater th
%This function is a threshold filter for the image by taking in an input
%image as well as a threshold. If the value of an element of an image is
%less than the threshold, the new image's value becomes 0 (black); otherwise, the value
'ecomes 255 (white).
%This function effectively takes the negative of a black and white image.
%Effectively, black becomes white and white becomes back. The grayscale
%image contains values from 0 to 255; So a value of 0 would become 255 an
NULLice versa. A value of 200 would
Lab 11: Matlab Basics
After this lab, you should be able to:
Use the Matlab text editor to create m-files (scripts and functions)
Understand the key components of a Matlab function, including the function header, input
parameters, return values, and the
Lab 4
(Mon Sep 27-Wed Sep 29 Lectures)
Task 1: Displaying a Students Letter Grade
In this task you will use selection to allow a student to enter their numerical exam grade
and receive the corresponding letter grade. As you may remember:
98 % 100 A+
92 %
Engineering 101
Fall 2010, Sections 100-200
Lab 5 (October 7-8, 2010)
Part A: Understanding how random numbers work in C+
Exercise (i):
Compile the following program, and execute it three times separately, from the command line. What do
you observe?
#incl
L ab 6: Binary Numbers and Character Manipulation
T ask 1a:
One method in which to find the number of digits in a decimal (base 10) number
is to divide the number by ten and keep dividing the resulting quotient by ten
until 0 is reached as the new quotien
Lab 7 (Thursday Oct 21 and Friday Oct 22)
Debugging Syntactical and Semantic Errors
Congratulations on your stellar performance in this class so far! Your instructor
has just employed you as an Engineering 101 GSI.
Lab 7 (Thursday Oct 21 and Friday Oct 22)
Debugging Syntactical and Semantic Errors
Congratulations on your stellar performance in this class so far! Your instructor
has just employed you as an Engineering 101 GSI.