-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdf_dGamma.m
More file actions
38 lines (35 loc) · 1.17 KB
/
df_dGamma.m
File metadata and controls
38 lines (35 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function [value] = df_dGamma(d, Gamma, B_m, B)
%
% [value] = df_dGamma(d, Gamma, B_m, B)
%
% This is the partial derivative of the f.m function with respect to Gamma.
%
% The inputs are d, Gamma, B_m, and B:
%
% d : the spin density, in arbitrary units
% Gamma : the HWHM linewidth, in Gauss
% B_m : the modulation amplitude, in Gauss
% B : the field value, in Gauss
%
% Argument checking
if ~isscalar(d) || ~isfloat(d)
error('df_dGamma:invalid_argument', ...
'd must be a scalar float');
elseif ~isscalar(Gamma) || ~isfloat(Gamma)
error('df_dGamma:invalid_argument', ...
'Gamma must be a scalar float');
elseif ~isscalar(B_m) || ~isfloat(B_m)
error('df_dGamma:invalid_argument', ...
'B_m must be a scalar float');
elseif ~isscalar(B) || ~isfloat(B)
error('df_dGamma:invalid_argument', ...
'B must be a scalar float');
end
% Please pardon the unreadable math....
value = imag( ...
(B_m*d*(((2*Gamma - 2*B*1i)*((1 - B_m^2/(4*(B + ...
1i*Gamma)^2))^(1/2) + 1))/2 - (B_m^2*1i)/(8*(1 - B_m^2/(4*(B + ...
1i*Gamma)^2))^(1/2)*(B + 1i*Gamma))))/(B_m^2/8 - (((1 - ...
B_m^2/(4*(B + 1i*Gamma)^2))^(1/2) + 1)*(B + 1i*Gamma)^2)/2)^2 ...
);
end