Negative index of matrix
1 回表示 (過去 30 日間)
古いコメントを表示
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/155467/image.jpeg)
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 件のコメント
回答 (1 件)
Walter Roberson
2016 年 8 月 4 日
1 件のコメント
Walter Roberson
2016 年 8 月 5 日
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.
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!