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 Kommentare

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

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 17 Jul. 2019

Kommentiert:

am 17 Jul. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by