I'd love for this to import spectra from monochromators. It almost accomplishes this, but misses key parameters for starting frequency, etc. (let alone the other available fields such as grating, dwell time etc.) I can send example .dm3 files if that would be helpful/interesting. Thanks again for the submission!

Still works on R2013a A few notes for those who are trying this- if you have other commands that have altered startup.m (like ezyfit) you have to seek those out and ensure that you have merged the startup.m files to accomplish all the startup tasks required (for instance, ezyfit, as well as the preserve_history functions).

I found my altered startup.m file in my "userpath" - try that on the command line to see what yours is. Matlab suggests using this path for startup.m as well as other user mfiles necessary for your work for easy path inclusion.

Note that any other startup.m files that are higher up in the path (in the path dialog in matlab) will be executed first, and all subsequent startup.m files will be ignored.

Utilizing these files and matlab's own startupsav.m file (located in toolbox/local) I now have a program that launches from where I left off before and pre-loads any variables that I was working with from a default matlab.mat file in the directory that I was working in previously.

Appears to work in R2011b if you merely take the transpose of one of the input matrices (I transposed "I" for the example code). The fit function requires matching sizes, with them opposing each other, the code does not complete.

CAREFULL BLIND USERS
In my hands this code is not working at all !!!
Just chek it by doing an horizontal linescan, the values are nothing but good.
Still, thanks for your work Hei.
I adopted a different strategy, consisting in drawing paralell lines after rotation of a rectangle:
Here is my "raw code" integrated in a larger routine, please email me if you want more info.
%%%
%linescan along the dots (x2,y2) and (x3,y3)
%width of the linsecan is the variable 'largeur', which is also the width of the rectangle I will rotate
%get the size of the line, length of the rectangle
longueur = sqrt((x3-x2).^2 + (y3-y2).^2);
%calculate the rotation angle
rotationAngle = acos((x3-x2)/longueur);
%building the rotation matrix
rotationArray = [cos(rotationAngle), -sin(rotationAngle); sin(rotationAngle), cos(rotationAngle)];
%get the rotation center
centerx = (x3 - x2)/2;
centery = (y3 - y2)/2;
%draw the rectangle for quantification before rotation
rectangle('position',[x2 + centerx - longueur/2, y2+ centery - largeur/2, longueur, largeur],'LineStyle','-','LineWidth',2,'EdgeColor','b')
%coordinates of the rectangle in the centered referential
vertices2 = cat(1,[-longueur/2,-largeur/2],[longueur/2,-largeur/2],[-longueur/2,largeur/2],[longueur/2,largeur/2]);
%New coordinates once rotated
rotrect2 = vertices2 * rotationArray;
%Put the rectangle in the old referential
rotrect2(:,1) = rotrect2(:,1) + x2 + centerx;
rotrect2(:,2) = rotrect2(:,2)+ y2 + centery;
%this is to draw the rotated rectangle
line([rotrect2(1,1),rotrect2(2,1)],[rotrect2(1,2),rotrect2(2,2)],'LineStyle','-','Color','w','LineWidth',2)
line([rotrect2(1,1),rotrect2(3,1)],[rotrect2(1,2),rotrect2(3,2)],'LineStyle','-','Color','w','LineWidth',2)
line([rotrect2(2,1),rotrect2(4,1)],[rotrect2(2,2),rotrect2(4,2)],'LineStyle','-','Color','w','LineWidth',2)
line([rotrect2(3,1),rotrect2(4,1)],[rotrect2(3,2),rotrect2(4,2)],'LineStyle','-','Color','w','LineWidth',2)
%get the equation of the lines forming the side of the rotated rectangle
pente = (rotrect2(3,2) - rotrect2(1,2))/(rotrect2(3,1) - rotrect2(1,1));
b1 = rotrect2(1,2) - pente * rotrect2(1,1);
b2 = rotrect2(2,2) - pente * rotrect2(2,1);
Fluoline2 = [];
%running improfile along the paralell lines
for j = 0 : (largeur-1)
xj1 = rotrect2(1,1) + ((rotrect2(3,1) - rotrect2(1,1))/(largeur-1))*j;
xj2 = rotrect2(2,1) + ((rotrect2(4,1) - rotrect2(2,1))/(largeur-1))*j;
yj1 = pente * xj1 + b1;
yj2 = pente * xj2 + b2;
%this will draw the dots for the linescans
line(xj1,yj1,'lineStyle','none','marker','*','markerEdgeColor','r')
line(xj2,yj2,'lineStyle','none','marker','*','markerEdgeColor','r')
%quantification along the line
Fluoline = improfile(M,[xj1,xj2],[yj1,yj2]);
%average of the intensity
Fluoline = mean(Fluoline,1);
Fluoline2 = cat(1,Fluoline2,Fluoline);
end
%Fluoline2 is a 'largeur by 1' vector giving the intensity along the different linescans.
%%%%%%%%
As said this code is extracted from my script. It can definitely be improved as I learned Matlab by myself playing around, but I think the idea is here, and the values are correct in my hands.
Hope this will be helpfull !!!
Damien.

1

09 May 2014

scatter3sph
SCATTER3SPH Plots a 3d scatter plot with 3D spheres of different size and color

I uploaded a new version that does not have the problem mentioned by DBS adn Allen (I think). Spheres will always look spherical, independently of the axis scaling.

Appears to work in R2011b if you merely take the transpose of one of the input matrices (I transposed "I" for the example code). The fit function requires matching sizes, with them opposing each other, the code does not complete.

Comment only