-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmathieu_a.m
More file actions
41 lines (32 loc) · 1.03 KB
/
Copy pathmathieu_a.m
File metadata and controls
41 lines (32 loc) · 1.03 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
39
40
41
function as = mathieu_a(Ne, q)
% This uses a finite-difference approximation to
% the Mathieu equation to create an eigenvalue
% problem. The solution to the eigenvalue problem
% gives the even Mathieu eigenvalues. This fcn returns
% the first Ne eigenvalues. The return is a row vector
% of ascending order.
% Number of sample points. I should make this depend
% upon how many eigenvalues are requested.
N = 251;
% My playing field -- fcn domain.
v = linspace(-pi, pi, N)';
% Preallocate space for eigenvalues.
as = zeros(1,Ne);
% Create finite difference matrix of Mathieu ODE.
Ae = make_matrix_e(N,q,v);
% Compute eigenvalues
opts = struct();
opts.maxit = 2000;
%opts.disp = 1;
opts.p = 50;
opts.tol = 1e-10;
%[S,D,flag] = eigs(Ae,2*Ne,'largestreal',opts);
[S,D,flag] = eigs(Ae,2*Ne,'sm',opts);
DD = -diag(D);
% Must sort eigenvalues
[DD,idx] = sort(DD);
% Store away eigenvalues. Must select only ever other one.
for j=1:2:length(DD)
as((j+1)/2) = DD(j);
end
end