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

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

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Mathematics에 대해 자세히 알아보기

태그

질문:

2019년 7월 17일

댓글:

2019년 7월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by