-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdf_dB_m.m
38 lines (35 loc) · 1.16 KB
/
df_dB_m.m
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_dB_m(d, Gamma, B_m, B)
%
% [value] = df_dB_m(d, Gamma, B_m, B)
%
% This is the partial derivative of the f.m function with respect to B_m.
%
% 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_dB_m:invalid_argument', ...
'd must be a scalar float');
elseif ~isscalar(Gamma) || ~isfloat(Gamma)
error('df_dB_m:invalid_argument', ...
'Gamma must be a scalar float');
elseif ~isscalar(B_m) || ~isfloat(B_m)
error('df_dB_m:invalid_argument', ...
'B_m must be a scalar float');
elseif ~isscalar(B) || ~isfloat(B)
error('df_dB_m:invalid_argument', ...
'B must be a scalar float');
end
% Please pardon the unreadable math....
value = imag( ...
(B_m*d*(B_m/4 + B_m/(8*(1 - B_m^2/(4*(B + ...
1i*Gamma)^2))^(1/2))))/(B_m^2/8 - (((1 - B_m^2/(4*(B + ...
1i*Gamma)^2))^(1/2) + 1)*(B + 1i*Gamma)^2)/2)^2 - d/(B_m^2/8 - ...
(((1 - B_m^2/(4*(B + 1i*Gamma)^2))^(1/2) + 1)*(B + 1i*Gamma)^2)/2) ...
);
end