MATLAB Tips

Posted on Aug 24, 2014 in Computer Science

Things under legendu.net/outdated are outdated technologies that the author does not plan to update any more. Please look for better alternatives.

Things on this page are fragmentary and immature notes/thoughts of the author. It is not meant to readers but rather for convenient reference of the author and future improvement.

  1. MATLAB uses float computing by default. 3/5 return 0.6 in MATLAB instead of 0 as will be returned in some other programming languages (e.g., Python).

  2. to get size of an object, md = whos(obj); md.bytes

  3. do we have x *= 2 in matlab, if not, use ultisnips to do it!!! and python, R, Mathematica, bash, etc.

  4. nohup matlab -nodesktop -nosplash -r "run('./RunSimulation10.m');quit;"

  5. num2str, numbers cannot be used as string directly

  6. Subscript indices must either be real positive integers or logicals. you confused matlab with your variable and the built-in function size!!!

  7. dlmwrite 'precision', edit the corresponding post

  8. You can use warning('off','all') to supress warnings in MATLAB.

  9. fitlm support the table data structure in R2015a and after but it only support matrix and dataset in R2013b and before.

  10. matlab's strength is for engineering uses, it is a piece of shit for statistical purposes ... stay away from matlab and live longer!

  11. matlab about array of string is too stupid, you need to use cell array of string ...

Statistics

  1. Use categorical to create a categorical array from data with values from a finite set of discrete categories. To group numeric data into categories, use discretize.

Data Structure

  1. Table in matlab is the equivalent data structure of data frame in R.

  2. table(c1, c2) to join tables/cells/varaibles horizontally

  3. You can use the function readtable to read the content of a file into a table.