In this article, we talk about some useful tricks of the trade in matlab.
run matlab on Linux server with
matlab -nodesktop -nodisplay -nosplash -nojvm. To run a script, you just need to type the script name without the extension name. e.g:
numel()to check whether the input image is RGB image or grayscale image.
repmat()to convert the grayscale image into pseudo RGB image.
1 2 3
fread()to calculate file content line number. Note that most file content is line-breaked by
'\n'. The ASCII code of
'\n'is 10. That is, we can directly count the number of
'\n', which equals to line number.
1 2 3 4 5 6
fread() reads the file in binary stream,
'*char' means reading a char each time and outputing as char too.