E7 Cheatsheet

# Where fhan is a functionhandle to a matlab function

• 3
• 50% (2) 1 out of 2 people found this document helpful

This preview shows page 2 - 3 out of 3 pages.

where fHan is a function_handle to a Matlab function representing f. The Matlab function that fHanrefers to should have 1 input (the function’s argument), and 1 output argument (the corresponding function value). Xopt and Yopt are the corresponding optimal values: Xopt is the value of x between L and U which minimizes f, Yopt is the value of f at Xopt. Other: type filename will tell you if it’s built in or print out lines from the file WHO lists the variables in the current workspace WHOS lists all the variables in the current workspace, together with information about their size, bytes, class, etc. NARGIN returns the number in input arguments that the function was called with (not the same as the number of argument in the function definition line) NARGOUT returns the number in output arguments that the function was called with ex) function [a1] = carg(b1,b2,b3) nin= nargin; Sunnie Mao Fall 2011 A\B is the matrix division of A into B A/B is the matrix division of B into A sprintf('%.2f%% blah blah', 12321.321321') returns 12321.32% blah blah double(A) converts to number char(55) converts to string finding zeros of a function (fzero) integrating a function (trapz, quad) integrating a differential equation (ode45) minimizing a fxn (fminbnd, fminsearch) The path command displays the searchpath for functions addpath, rmpath, savepath load(‘filename’) retrieves all variables from a file given a full pathname repmat(A,M,N) creates a large matrix B consisting of an M-by-N tiling of copies of A. The size of B is [size(A,1)*M, size(A,2)*N] NUMEL Number of elements in an array or subscripted array expression DIFF Difference and approximate derivative. DIFF(X), for a vector X, is [X(2)-X(1) X(3)-X(2) ... X(n)-X(n-1)] CUMSUM(X,DIM)/CUMPROD(X,DIM) works along the dimension DIM ISEQUAL(A,B) returns logical 1 (TRUE) if arrays A and B are the same size and contain the same values, and logical 0 (FALSE) otherwise Format short bank rat compact long doesn’t change the precision str = 'How much MATLAB can I do in one day?' strfind(str, 'MATLAB') locates the string 'MATLAB' within the string str strfind('MATLAB', str) 'str' is not in 'MATLAB' so it produced an empty array 'e' - 'E' subtracts the numbers associated with the strings strcmp('the', 'The') compares two strings Since 'the' and 'The' are not the same due to the case difference in T, the result was 0. strcmpi('the', 'The') compares two strings

Subscribe to view the full document.

and returns logical 1 (true) if they are the same except for case
• Spring '14
• exclusive or, cell array, Yopt, Execute command group

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern