clear all;
x = chebfun('x',[-3.5 3.5]);
w =(x.*x);
N = 2;
P = OrthPoly(w,N);
format long
figure
plot(P)
title('Orthogonal polynomials on [-3.5,3.5] wrt w = (x.*x)');
I am not able to get the values of P(:,1) and P(:,2). I am able to plot it. Any suggestions?

4 comentarios

KALYAN ACHARJYA
KALYAN ACHARJYA el 17 de Jul. de 2019
Please do share chebfun?
KSSV
KSSV el 17 de Jul. de 2019
Function orthPoly also...
Shashank Mishra
Shashank Mishra el 17 de Jul. de 2019
function P = OrthPoly(w,N)
if isnumeric(w),
%w=x*x;
w = chebfun(w,[-1 1]);
end
d = w.ends; % The domain
x = chebfun('x',d); % Linear chebfun
P(:,1) = chebfun(1./sqrt(sum(w)),d); % The constant (normalised)
for k = 1:N;
% xk = x.^k;
xk = x.*P(:,k);
P(:,k+1) = xk;
for j = 1:k % Subtract out the components
C = sum(w.*xk.*P(:,j));
P(:,k+1) = P(:,k+1) - C*P(:,j);
end
P(:,k+1) = P(:,k+1)./sqrt(sum(w.*P(:,k+1).^2)); % normalise
end
end

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Mathematics en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 17 de Jul. de 2019

Comentada:

el 17 de Jul. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by