What would you add to my Matlab cheatsheet ?

1 view (last 30 days)
I am always adding and removing stuff for my Matlab cheatsheet and would like everyones opinion on what they would add/remove.
I like to have even the very basic stuff there so i can share it with others.
Cheers ps. would love to hear what you are using Matlab for when you suggest changes

Accepted Answer

Jan
Jan on 25 Aug 2013
Edited: Jan on 25 Aug 2013
  • The page numbers 91 and 92 seems to imply, that there are some more hints.
  • I would omit "median(x) median" and "mean(x) mean".
  • cd is mire direct than pwd to get the current directory.
  • "sprintf(x) formated data to a string" does not mention the more interesting format specifiers.
  • fprintf is important also, while "disp(x) Displays the string x" leaves out the real power of disp to display all Matlab arrays.
  • The leaner a cheat sheet, the better. So "It is easy to create functions:" does not help.
  • "bsxfun(fun,A,B) fun is elementwise applied" does not hit the point of the auto-expanding of singleton dimensions.
  • "int16(x)=y" is no valid Matlab syntax.
  • Matlab does not have a "sqr" function.
  • "find(A>5) nds element nr. >5": No, FIND does not determine the number, but the indices.
  • "B=repmat(A,m,n) Makes B from A" does not hit the point of the replication.
  • kron() is missing, but it solves many problems.
  • zeros, ones, NaN, Inf could be summarized in a single line.
  • "figure(j) graphics object j, j is an integer": The handle of figures can be an integer for backward compatibility. Non-integer handles are safer.
  • "get(j) returns information on figure j": get operates on all HG-objects and a lot of other objects also, see help get.
  • "subplot(a,b,c) Creates plot aXb matrix and puts figure into position c" is not clear. subplot does not create a figure, but an axes object.
  • In "print(figure(CurrentFigure),'-depsc2','path\image.eps')" the figure command is useless. Better: "print(FigureHandle,'-depsc2','path\image.eps')".
  • "isnummeric(x)" has one "m"
  • The difference between "&&" and "&" is important.
  • Duplicates can be omitted: ver, [A;B] and x=[1; 2; 3], diff,
  • The most important detail of inv(A) is, that it is usually not required and \ is more efficient.
  • "size(x) rows and cols" matters matrices only, but size has more features.
This means, that I'd apply fixes at first, omit redundant and rarely needed information, before adding further commands. And finally I'm not sure for which kind of user this sheet might be useful for. You personally have learned enough Matlab during creating the sheet, that you do not need it anymore. And for a Matlab beginner would be confused by the omitted or inaccurate details.
  1 Comment
Thor
Thor on 26 Aug 2013
Thanks :) I used most of your suggestions!

Sign in to comment.

More Answers (2)

Jan
Jan on 18 Aug 2013
  • j:i:k does not create j, j+i, ..., k, see: 1:2:4
  • "while switch" might mean "switch case"
  2 Comments
Richard Brown
Richard Brown on 18 Aug 2013
While we're at it, transpose is .'

Sign in to comment.


Image Analyst
Image Analyst on 19 Aug 2013
When you're adding x and y you don't need the dot, you can just do x+y. You might run it through a spellchecker to correct numerous spelling errors. You might add intmax and realmax to the list of useful built in functions.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!