Last modified: Jun, 2014
It happened to my fresh installed Xubuntu 11.10: I could not change the font type and size in a figure. This might have something to do with Matlab itself — the fonts in figures were rendered by the old X while fonts outside were done with Java. To overcome this problem, one possible solution was to install necessary DPI fonts:
sudo apt-get install xfonts-100dpi xfonts-75dpi
Reference:
(Installation of ‘xfonts-100dpi’ and ‘xfonts-75dpi’ also solved the default messy fonts problem of Google Earth in Kubuntu/Xubuntu.)
NOTE: One can also use “importdata” function in MATLAB.
Reference:
One can use the “‘Visible’” axis property to remove ALL axes, including tick marks and labels:
A quick and dirty way to get rid of just one axis: remove all tick marks and then set its color to white (or whatever the current background colour may be:
The error usually goes like this in a fresh installed Matlab 2011b on Ubuntu
/matlab/bin/util/oscheck.sh: 605: /lib64/libc.so.6: not found
The solution to this problem:
For Ubuntu 12.04 64-bit, the fix is
sudo ln -s /lib/x86_64-linux-gnu/libc.so.6 /lib64/libc.so.6
Other Linux distros can adapt similar fix. For example, for 32-bit Linux:
sudo ln -s /lib/i386-linux-gnu/libc-2.13.so /lib/libc.so.6
For 64-bit:
sudo ln -s /lib64/x86_64-linux-gnu/libc-2.13.so /lib64/libc.so.6
It is handy to access external programs in MATLAB. But sometimes libraries are reported missing. For example, I was trying to compile a FORTRAN script with gfortran in my 64-bit Ubuntu system
and MATLAB complained
/home/user/MATLAB/R2011b/sys/os/glnxa64/libgfortran.so.3: version `GFORTRAN_1.4' not found
The fix is to symbolically link system’s libraries to MATLAB’s corresponding directory.
cd /home/user/MATLAB/R2011b/sys/os/glnxa64
mv libgfortran.so.3 libgfortran.so.3_bak
ln -s /usr/lib/x86_64-linux-gnu/libgfortran.so.3
For example, if one needs to solve an equation ‘sin(x)=a*x+b’ within the main function, while ‘a’ and ‘b’ are calculated previously in the main function. In this case, the main function needs to pass the parameters ‘a’ and ‘b’ to the equation.
One can create another function ‘func2.m’ in which
And in the main function, solve this equation:
Sometimes I need to add automatically generated legend to the plot. For example, I have an array
And I need to make the values in variable “‘arr’” as the legend entries. That is, I have five curves, and each curve corresponds to “a=1”, “a=2”, “a=3”, “a=4” and “a=5” in legend. One way to automate this legend generation is
Note that the variable “leg_str” is a cell, not an array (It seems “legend.m” deals strings in cell format).
Take this example string
>> regexprep(test_str, 'San Francisco', 'Boston')
ans =
'if you are going to Boston'
http://www.mathworks.com/matlabcentral/answers/25381-how-to-show-partial-legend-in-figure
http://www.mathworks.com/matlabcentral/answers/16667-how-to-remove-repeating-elements-from-an-array
http://stackoverflow.com/questions/15381188/complement-subset-in-matlab