Negative index of matrix

2 次查看(过去 30 天)
Burak
Burak 2016-8-4
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

回答(1 个)

Walter Roberson
Walter Roberson 2016-8-4
  1 个评论
Walter Roberson
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 CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by