MATLAB Code for MOT Lifetime – Linear Fitting

% #1 read .cvs file
C=uiimport(‘FileFolder\C2mot-gradient200032.txt’);

x=1:length(C.data(:,1));
plot(x,C.data(:,2));

% #2 find I_max
B=C.data(14000:17000,2);
I_max=mean(B);

w=log(I_max-C.data(:,2));

% #5 linear fit =>> slope is -1/tau =>> This is the first return value of
%polyfit
p_flu=polyfit(C.data(7200:10000,1),w(7200:10000),1);
tau=-1/p_flu(1)

MLoad= I_max-(exp(p_flu(2)).*(exp(-C.data(:,1)/tau)));
plot(x(5000:25000),C.data(5000:25000,2),x(5000:25000),MLoad(5000:25000))

Advertisements

Tags: , , ,

About vekin

I'm mostly a scientist, but occasionally a writer and an artist, and most definitely a dreamer.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: