Solving Eigenvalue problem (2nd order ODE)

10 visualizzazioni (ultimi 30 giorni)
Rob
Rob il 12 Feb 2021
Modificato: Rob il 12 Feb 2021
I am trying to solve the following eigenvalue problem:
with BCs .
(z) is a vector with size (,1), is the eigenvalue, and is the eigenvector. I am attempting to find for the lowest mode (i.e. solution with ) and the corresponding using the following code:
Amatrix = zeros(nz-1,nz-1);
Coeff = zeros(nz,1);
for iR = 1 : nz
Coeff(iR) = 1/N2(iR);
if isnan(Coeff(iR))
Coeff(iR)=Coeff(iR-1);
end
end
for iA = 2 : (nz-2)
Amatrix(iA,iA) = -2/(DZ(iA)*DZ(iA))*Coeff(iA);
Amatrix(iA,iA-1) = 1/(DZ(iA)*DZ(iA))*Coeff(iA);
Amatrix(iA,iA+1) = 1/(DZ(iA)*DZ(iA))*Coeff(iA);
end
Amatrix(1,1) = -2/(DZ(1)*DZ(1))*Coeff(1);
Amatrix(1,2) = 1/(DZ(1)*DZ(1))*Coeff(1);
Amatrix(nz-1,nz-1) = -2/(DZ(nz-1)*DZ(nz-1))*Coeff(nz-1);
Amatrix(nz-1,nz-2) = 1/(DZ(nz-1)*DZ(nz-1))*Coeff(nz-1);
[V,DD] = eig(full(Amatrix));
PHI = zeros(100,1);
for iz = 1 : 99
PHI(iz,1)=V(iz,1); %Selecting tthe first mode?
end
C = DD.^{-0.5}
When I execute this code, however, does not match the theory; specifically the mode-1 () structure is not present ( should only have one extrema between and ). I have included the plot below of normalized and for clarity.
Any advice with where I'm going wrong would be greatly appreciated. Thanks in advance for your help!

Risposte (1)

Alan Stevens
Alan Stevens il 12 Feb 2021
Your mathematical equation has the inverse of the eigenvalue squared, but your code calcukates the inverse of the square root of the eigenvalue. No idea if this solves your problem as you don't specify N2 or DZ, so can't run your coding.
  1 Commento
Rob
Rob il 12 Feb 2021
Modificato: Rob il 12 Feb 2021
Thanks for your comment. DZ = 46.88*ones(100,1) and
N2 = 1.0e-04 *
0.0279
0.0391
0.0459
0.0558
0.0659
0.0737
0.0798
0.0819
0.0828
0.0803
0.0751
0.0694
0.0656
0.0673
0.0764
0.0839
0.0840
0.0800
0.0758
0.0745
0.0775
0.0847
0.0942
0.1014
0.1004
0.0891
0.0780
0.0743
0.0759
0.0794
0.0823
0.0827
0.0800
0.0741
0.0675
0.0623
0.0592
0.0570
0.0550
0.0528
0.0506
0.0487
0.0472
0.0460
0.0449
0.0439
0.0430
0.0420
0.0411
0.0400
0.0390
0.0380
0.0370
0.0360
0.0351
0.0344
0.0337
0.0331
0.0327
0.0323
0.0321
0.0318
0.0317
0.0315
0.0313
0.0311
0.0309
0.0307
0.0304
0.0301
0.0298
0.0294
0.0291
0.0287
0.0283
0.0279
0.0275
0.0272
0.0268
0.0265
0.0262
0.0259
0.0257
0.0255
0.0254
0.0253
0.0253
0.0254
0.0255
0.0258
0.0261
0.0265
0.0270
0.0276
0.0283
0.0289
0.0297
0.0306
0.0317
0.0330
I've calculated c, rather than c^2, hence the inverse square root. I have edited the variable in the original code to reflect this.

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by