What would you add to my Matlab cheatsheet ?

6 visualizzazioni (ultimi 30 giorni)
Thor
Thor il 15 Ago 2013
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

Risposta accettata

Jan
Jan il 25 Ago 2013
Modificato: Jan il 25 Ago 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.

Più risposte (2)

Jan
Jan il 18 Ago 2013
  • j:i:k does not create j, j+i, ..., k, see: 1:2:4
  • "while switch" might mean "switch case"
  2 Commenti
Thor
Thor il 18 Ago 2013
Thanks
You are right that j:i:k does not exactly do that, but it is mostly right. Ofcourse like you point out if we do 1:2:4 we get 1 3. And yup the while switch was meant as switch case :) thank you
No functions you would add :) ?
Richard Brown
Richard Brown il 18 Ago 2013
While we're at it, transpose is .'

Accedi per commentare.


Image Analyst
Image Analyst il 19 Ago 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.

Categorie

Scopri di più su Entering Commands in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by