Negative index of matrix
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi , I am trying to calculate gaunt coefficients for μ=-m. But I am stuck with negative index of matrix calculation.If anyone can help me I'll appreciate. Thanks for your help.
here is my code.
% clc
clear all
N_cut=2;
for n=1:N_cut
for m=-n:n
for v=m:N_cut
for p=abs(n-v):2:n+v
a(n,m,v,p+1)=(2*p+1)*sqrt((factorial(n+m)*factorial(v-m))/(factorial(n-m)*factorial(v+m)))*...
Wigner3j(n,v,p,0,0,0)*Wigner3j(n,v,p,m,-m,0);
end
end
end
end
0 Commenti
Risposte (1)
Walter Roberson
il 4 Ago 2016
1 Commento
Walter Roberson
il 5 Ago 2016
To expand: any time your indices are not consecutive integers starting from 1, you can use this pattern:
m_vals = -m:m; %vector of the allowed values
for m_idx = 1 : length(m_vals)
m = m_vals(m_idx);
....
a(n,m_idx,v,p+1) = ....
end
That is, you create a vector with the values, loop over the indices of that vector, set your variable of interest to the vector indexed at the index variable, and when you go to store the value use the index variable.
You do, however, have to watch out for the problem that your values might line up with each other, since your -m:m will vary in size as n changes. Your formula is for the calculation of a particular set of 4 inputs but you are trying to calculate it over an irregular region, and you are trying to store that irregular region into a rectangular hypercube. The location within the hypercube that you store the irregular region is not well defined in what you posted.
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!