Create a table with a generated polynomial
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Image Analyst
am 11 Okt. 2018
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?
Antworten (0)
Siehe auch
Kategorien
Mehr zu Tables finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!