The following program will evaluate the
of order
at a particular value of
.
and
values are taken from the previous item.
function z=tp(A,B,x,M)
z=A(1);
for j=1:M
z=z+A(j+1)*cos(j*x)+B(j+1)*sin(j*x);
end
Study the following commands:
>>x=-pi:.01:pi
>>y=tp(A,B,x,M)
>>plot(x,y,X,Y,'o')
Repeat the procedure for the
-values, 10, 20, 50. Compare the results
Solution:
function calc(M)
X=-pi:.01:pi;
Y=X;
[A,B] = tpcoeff(X,Y,M);
x=-pi:.01:pi;
y=tp(A,B,x,M);
plot(x,y,X,Y,'-');
function drawer
ARR= [10,20,50,100];
len=length(ARR);
for i=1:len
subplot(len,1,i)
calc(ARR(i));
end
save with the names calc.m and drawer.m. Then;
>> drawer
Figure 6.11:
subplot(len,1,i).
|
This solution is supplied by Ömer Sezgin Ugurlu.