





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A part of cs112 scientific computation course materials at wellesley college. It covers various matrix operations, indexing, and analyzing table data. The document also includes instructions on how to plot trends in performance levels and print changes in results. The data presented is related to the mcas test in mathematics, grade 10.
Typology: Exams
1 / 9
This page cannot be seen from the preview
Don't miss anything!
More matrices 7-
nums = [ 1 2 3 4 5; 6 7 8 9 10; ... 11 12 13 0 15; 16 17 18 19 20]; val = nums(2, 3); nums(3, 4) = 14;
More matrices 7-
Indexing with colon notation
To refer to anentire column of a matrix, provide : as the first index and the column number as the second index >> nums(:, 3) ans = 3 8 13 18
To refer to anentire row of a matrix, provide : as the second index and the row number as the first index >> nums(2, :) ans = 6 7 8 9 10
nums 5 10
More matrices 7-
Analyzing table data
level (^1998 1999 2000 2001 2002 2003 2004 ) advanced (^7 9 15 18 20 24 29 ) proficient (^17 15 18 27 24 27 28 ) needs improvement 24 23 22 30 31 29 28 24 failing (^52 53 45 25 25 20 15 )
More matrices 7-
Finally, ...
Suppose we want to print the change in results between 1998 and 2005 for each performance level…
How do we do this?
More matrices 7-
Printing changes in results
% print total change in results between 1998 and 2005 totalChange = results(:, end) - results(:, 1); disp('Change in performance between 1998 and 2005:‘); disp(['advanced: ' num2str(totalChange(1)) '%‘]); disp(['proficient: ' num2str(totalChange(2)) '%‘]); disp(['needs improvement: ' num2str(totalChange(3)) '%‘]); disp(['failing: ' num2str(totalChange(4)) '%‘]);
More matrices 7-
Time-out exercise
For each year, compute aweighted sum of the four percentages, using a weight of 1 for “advanced”, 2 for “proficient”, 3 for “needs improvement” and 4 for “failing”* overallPerformance =
Add a new row to the results matrix that stores these weighted sums
More matrices 7-
More indexing with colon notation
We can use colon notation to refer to arange of indices within a column or row of a matrix
nums 5 10
More matrices 7-
Time-out exercise
Given the original ages matrix, write two statements that each assign the variable numAdults to the total number of age values that are 18 or over
One statement should use sum and the other should use length
More matrices 7-
Creating synthetic images
Using colon notation, we can create a synthetic image that contains patches of constant brightness image = zeros(128, 128); image(10:40, 50:80) = 1.0; image(60:100, 80:115) = 0.8; image(90:110, 30:100) = 0.4; Copy rectangular regions of one image into another image patch = image(60:110, 60:110); newImage = zeros(128,128); newImage(10:60, 10:60) = patch; newImage(10:60, 70:120) = patch; newImage(55:75, 55:75) = image(90:110, 70:90); newImage(85:120, 40:80) = newImage(40:75, 40:80);
More matrices 7-
Let’s make a quilt
Suppose we want to create the following image - How do we plan the code?
We can begin by making a single patch:
More matrices 7-
Making the patch
First draw a picture of the pattern, with coordinates of key points and brightness values:
Then write the code…
patch (^) 0.0 0.5 1.