All entries of array except certain indices in octave/matlab

Posted on Wed 07 December 2011 in Misc • Tagged with Matlab, octave

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 …

Continue reading

Plasmonic materials in MEEP

Posted on Wed 27 April 2011 in Plasmonics • Tagged with electromagnetism, FDTD, Free Software, Matlab, MEEP, octave, photonics, Plasmonics, SERS


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 …

Continue reading

Adding a title to colobar in Matlab

Posted on Sun 21 March 2010 in Misc • Tagged with Matlab

To insert a title to the colorbar in matlab. 

Use the following code (Source):

% Loads a data for the example 
load mandrill

% Plots an image for the example 

% Inserts a colorbar. a handle is created 

% sets the ylabel property of the handle t. 
set(get(t …

Continue reading

Radiation from an oscillating dipole

Posted on Thu 14 January 2010 in Plasmonics • Tagged with electromagnetism, Matlab, Plasmonics

The electric field from an oscillating dipole is given by:, where [tex]\hat{r}[/tex] is the position vector, [tex] \omega [/tex] is the frequency of dipole oscillation, [tex]\textbf{p}[/tex] is the dipole moment. The two terms in the electric field consists of 1) near field (area near …

Continue reading

Smooth image in matlab

Posted on Sun 10 January 2010 in Misc • Tagged with graphs, Matlab

In matlab, sometimes I prefer to plot a image for mesh data instead of surf and use view(2) (view(2) gives the top view of the surface plot). However,
imagesc(x,y,z) shading 'interp'
does not work. This problem can be solved by using:
pcolor(x,y,z …

Continue reading