Spaces in strings in matlab/octave

To get spaces in the strings to work in matlab or octave, use t1={‘test test’} Result is t1 = { [1,1] = test test } t2=strcat({‘test test ‘},{‘blah blah’}) Result is t2 = { [1,1] = test test blah blah } you can use this string in your figures by plot([1:4]) title(t2{})

All entries of array except certain indices in octave/matlab

In Octave or Matlab, some times one needs to eliminate certain elements in an array. For example, if a=[10,20,30,40,50,60]; and suppose I want to create a matrix “b” such that it has all the elements of “a” except 20 and 40. This can be achieved by: b=a(1:end~=2&1:end~=4); The result is: b =    10   30   50   60

Plasmonic materials in MEEP

The aim of this post is to share my experience in incorporating dielectric function of metals such as gold and silver into MEEP (a free finite difference time domain package) code. The incorporation is not an easy task and can be daunting for the first time user. Metals such as gold and silver have both Drude and Lorentz components for the dielectric function. There are many forms of Lorentz-Drude expressions in literature with slight notation differences. I prefer the Lorentz-Drude expression mentioned in Rakic et al., Optical properties of metallic films for vertical-cavity optoelectronic devices, Applied Optics (1998) and Read More …

Adding a title to colobar in Matlab

To insert a title to the colorbar in matlab.  Use the following code(Source): load mandrill % Loads a data for the example image(X) % Plots an image for the example t=colorbar;% Inserts a colorbar. a handle is created set(get(t,’ylabel’),’string’,’My colorbar title’,’Fontsize’,10) % sets the ylabel property of the handle t.