



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
Material Type: Notes; Class: Introduction to Scientific Computing and Problem Solving; Subject: Computer Science; University: Brown University; Term: Spring 2007;
Typology: Study notes
1 / 6
This page cannot be seen from the preview
Don't miss anything!




CS004 Introduction to Scientific Computing Hughes
Syntax Description reshape(A, m, n) Reshapes A from a k Ă p matrix into a m Ă n one. Note: kp = mn must hold. mod(a, b) Returns the remainder of a when divided by b. mod(a, 0) == a by convention. Useful for indexing some arrays. abs(A) Returns the absolute values or complex magnitudes of the elements of A. round(A) Rounds the entries of A to the nearest integer. floor(A) Rounds each entry of A to the nearest integer less than or equal to that entry. ceil(A) Rounds each entry of A to the nearest integer greater than or equal to that entry. A .* B Multiplies each element of A by the corresponding element of B. A and B must have the same dimensions. A ./ B Divides each element of A by the corresponding element of B. A and B must have the same dimensions. A .^ n Raises each entry of A to the nth power. zeros(n) (^) Returns a n Ă n or n Ă m matrix of zeros zeros(n, m) ones(n) Returns a n Ă n or n Ă m matrix of ones ones(n, m)
whos Returns the name, number of elements, size in bytes, and type of all variables currently active in the workspace; specifying the variable name limits the output to that variable.
whos(âvariablenameâ˛)
numel(A) Returns the number of elements in matrix A. [r, c] = size(A) Returns the vector: [# of rows, # of columns]. size (A, 1) Returns the number of rows of A. size (A, 2) Returns the number of columns of A. find(A) Returns the indices of the nonzero elements of A. find(A == n) Returns the indices of the elements of A equal to n. sum(A) For a n Ă m matrix A, returns a 1 Ă m vector, containing the sums of each column. sum(A, dim) Returns a vector of sums along the specified dimensions, where dim = 1 sums across the rows and dim = 2 sums across columns. cumsum(A) Returns a matrix of the same dimensions as A whose elements are the cumulative sum of each column. [m, n] = ind2sub(size, index) Returns the (m, n) index corresponding to the linear index index. index = sub2ind(size, m, n) Returns the linear index corresponding to the indices (m, n).
rand(n) Returns either a n Ă n or n Ă m matrix of numbers chosen rand(n, m) randomly between 0 and 1 (inclusive). randn(n) Similar to rand, but instead draws the values from a normal randn(n, m) distribution with mean 0 and standard deviation 1. randint(n) Creates a n Ă n or n Ă m matrix whose entries are either 0 randint(n, m) or 1 with equal probability. randint(n,m,k) Creates a n Ă m matrix whose entries are random integers between 0 and k â 1.