To talk on Icrontic, just register!

It only takes 30 seconds.

Have an account? Sign in:

Forgot?
lacy1104
New to the neighborhood
lacy1104
2 Posts

Malab Help!!

I am new with matlab and I am very confused on how to write this. Can anyone help.

1. Write the following MATLAB function
function [C,X, Y ] = Chebyshev (func, N, a, b)
to construct and evaluate an interpolating polynomial of degree N for f(x) over [a, b], with the zeros of the Chebyshev polynomial of degree N + 1 as nodes.

Inputs: func - the string function to be approximated
a - left end point
b - right end point
N - the degree of the interpolating polynomial

Outputs: C - the vector containing the coefficients of the interpolating polynomial
X - the abscissa vector
Y - the ordinate vector
The results are to be in this format:
Tables for the results
x f(x) y f(x) − y
0.5
0.8
0.9
0.99

Data and Results for Problem # 1
1. f(x) = ln(x + 3) over [−1, 1]
N = 3
2. f(x) = sin x + cos x over [−1, 1]
N = 2
3. f(x) = cos x over [−1, 1].
N = 2
lacy1104
New to the neighborhood
lacy1104
2 Posts
So far this is what i did but i dont know how to call a function, can anyone help?
function [C,X,Y] = Chebyshev( func, N, a, b )

X=(b+a-(b-a)*cos((2*(0:N-1)+1)*pi/(2*N)))/2;
Y = eval(func,X);

C=zeros(1,N+1);


call function as
[C,X,Y] = Chebyshev( ['cos(X)'], 2, -1, 1)
Go Back   Icrontic Forums > Tech: Software > General Software > Matlab Help
Jump to
This Thread Search this Thread
Search this Thread:

Advanced Search


Current time: 8:36pm (GMT)
Powered by vBulletin®
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Get Vanilla instead. Trust me.