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.
-
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). -
to get size of an object, md = whos(obj); md.bytes
-
do we have
x *= 2
in matlab, if not, use ultisnips to do it!!! and python, R, Mathematica, bash, etc. -
nohup matlab -nodesktop -nosplash -r "run('./RunSimulation10.m');quit;"
-
num2str, numbers cannot be used as string directly
-
Subscript indices must either be real positive integers or logicals. you confused matlab with your variable and the built-in function size!!!
-
dlmwrite 'precision', edit the corresponding post
-
You can use
warning('off','all')
to supress warnings in MATLAB. -
fitlm support the table data structure in R2015a and after but it only support matrix and dataset in R2013b and before.
-
matlab's strength is for engineering uses, it is a piece of shit for statistical purposes ... stay away from matlab and live longer!
-
matlab about array of string is too stupid, you need to use cell array of string ...
Statistics
- 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
-
Table in matlab is the equivalent data structure of data frame in R.
-
table(c1, c2) to join tables/cells/varaibles horizontally
-
You can use the function
readtable
to read the content of a file into a table.