Create a table with a generated polynomial
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi there! I am using a code that generates and computes a polynomial, but I am now not interested in the result but in the form of the polynomial, therefore I would like to display each polynomial generated in a table having in each raw a polynomial. Hereby I let you the code.
for j=1:200
% calculate the n value
n1 = (-1 + sqrt(1 + 8 * j)) / 2;
n = floor(n1);
if n1 == n
n = n - 1;
end % if statement
% calculate the m value
k = (n+1)*(n+2)/2;
d = k - j;
m1 = n - 2*d;
m = abs(m1);
% calculate the sc value
sc = ' ';
if m1 > 0
sc = 's';
end % if statement
if m1 < 0
sc = 'c';
end % if statement
Rnm = zeros(size(rho));
for s=0:(n-m)/2
numerator = (-1)^s * factorial(n-s);
denominator = factorial(s)*factorial((n+m)/2-s)*factorial((n-m)/2-s);
Rnm = Rnm + (numerator / denominator) * rho.^(n-2*s);
end % for s statement
% 3 cases. sc=' ', 's', 'c'.
theFactor = 1;
switch sc
case ' '
% means m=0
theFactor = sqrt(n+1);
Zern_i(:, :, j) =theFactor* Rnm;
case 's'
theFactor = sqrt(2*(n+1));
Zern_i(:, :, j) =theFactor* Rnm .* sin(m*theta);
case 'c'
theFactor = sqrt(2*(n+1));
Zern_i(:, :, j) =theFactor* Rnm .* cos(m*theta);
end
end
댓글 수: 3
Image Analyst
2018년 10월 11일
I don't see any table. You need to use the table() function, unless you simple want a matrix of doubles. To generate polynomial values, have you seen the polyval() function?
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!