how can i solve this?
5 ビュー (過去 30 日間)
古いコメントを表示
I am trying to solve this really simple code problems, but I wan not able:
Omega=zeros(1,800);
Y=cos(km2rad(20));
for n=1:800
Omega(n)=(1/2)*[(legendreP(n-1,Y))-(legendreP(n+1,Y))];
end
Omegazero=(1/2)*(1-Y);
OmegaT=[Omegazero Omega];
********************************************************************
The real formulation is:
Omega(n)=1/2[Pn-1(Y)-Pn+1(Y)],
OmegaZero=1/2(1-Y)
Y=cos(20km) that should be in radian.
I know the answer but I can not reach to real answer. I got something really different.
Thanks
0 件のコメント
採用された回答
Walter Roberson
2015 年 11 月 29 日
編集済み: Walter Roberson
2015 年 11 月 29 日
I could see how
Bn=2n-1/n+1*Bn-1*cos(psi)-(n-2/n+1)*Bn-2
could translate to
B(n) = (2*n-1)/(n+1) * B(n-1) * cos(psi) - (n-2)/(n+1)*B(n-2);
but where are your "3" coming from in your line
B(n)=((((2*n)-3)/(n))*B(n-1)*cos(psi))-(((n-3)/(n))*B(n-2));
?
7 件のコメント
Walter Roberson
2015 年 11 月 30 日
That calculation looks okay.
legendreP is part of the symbolic toolbox, so it is only invoked if at least one of the arguments to it is symbolic, but you are wanting to invoke it with arguments that are completely numeric. legendreP(numeric,numeric) would not be found -- without a symbolic parameter MATLAB does not have reason to look in the symbolic toolbox for a match.
legendreP = @(n,x) double( feval(symengine, 'legendreP', n, x) );
locally defines legendreP as an anonymous function with two arguments that invokes the symbolic engine (MuPAD) directly and tells the symbolic engine to execute the MuPAD function legendreP with the two given arguments. With this direct call, MATLAB will be able to find the correct function and execute it, returning a symbolic number as a solution; double() then converts the symbolic number to a floating point number that MATLAB can use.
Walter Roberson
2015 年 12 月 2 日
編集済み: Walter Roberson
2015 年 12 月 2 日
Mahdiye comments "Wonderful answer"
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!