-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathab2rf.m
More file actions
29 lines (26 loc) · 729 Bytes
/
ab2rf.m
File metadata and controls
29 lines (26 loc) · 729 Bytes
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
% ab2rf - take two polynomials for alpha and beta, and return an
% rf waveform that would generate them.
%
% COMPLEX RF VERSION
%
% rf = ab2rf(a, b)
% a, b - polynomials for alpha and beta
% rf - rf waveform that produces alpha and beta under the hard pulse
% approximation.
%
% Courtesy John Pauly, 2004
% (c) Board of Trustees, Leland Stanford Junior University
function [rf] = ab2rf(ac,bc)
n = length(ac);
j = sqrt(-1);
for i=n:-1:1,
c(i) = sqrt(1/(1+abs(bc(i)/ac(i))^2));
s(i) = conj(c(i)*bc(i)/ac(i));
theta = atan2(abs(s(i)),c(i));
psi = angle(s(i));
rf(i) = 2*(theta*cos(psi)+j*theta*sin(psi));
acn = c(i)*ac + s(i)*bc;
bcn = -conj(s(i))*ac + c(i)*bc;
ac = acn(2:i);
bc = bcn(1:i-1);
end;