Create a table with a generated polynomial

4 ビュー (過去 30 日間)
Luis Paniagua
Luis Paniagua 2018 年 10 月 11 日
コメント済み: Image Analyst 2018 年 10 月 11 日
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 件のコメント
Luis Paniagua
Luis Paniagua 2018 年 10 月 11 日
I want to have asingle column table that displays in each row the avobe generated polynomial, so the code generates 200 different polynomials, and I want a table with 200 rows, and in each one there must be a formula that shows how is the shape of the polynomial.
Image Analyst
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 ExchangeTables についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by