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 commentaires

KALYAN ACHARJYA
KALYAN ACHARJYA le 17 Juil 2019
Please do share chebfun?
KSSV
KSSV le 17 Juil 2019
Function orthPoly also...
Shashank Mishra
Shashank Mishra le 17 Juil 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

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Mathematics dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by