y|[gۑiTj𓚗z

 

1D

vO

x=-10:0.01:10;

y1=zeros(size(x));

y2=zeros(size(x));

n1=4;

n2=10;

 

for i=1:n1

  y1=y1+(-1)^(i+1)*sin(i*x)/i;

end

y1=y1*2/pi;

 

for i=1:n2

  y2=y2+(-1)^(i+1)*sin(i*x)/i;

end

y2=y2*2/pi;

 

plot(x,y1,x,y2)

legend('n=4','n=10')

grid('on')

s

 

 

2D

vO

x=-10:2:8;

y=[-990 -520 -201 -60 -10 2 12 62 220 510];

p=polyfit(x,y,3)

x1=-10:0.1:8;

y1=polyval(p,x1);

plot(x,y,'o',x1,y1)

legend('data','line')

grid('on')

p =

   0.9969648   -0.0062646   -0.1437451    2.2657343

 

3D

vO

f=[-1 0 1 -6 0];

g=[1 4 5 2];

while(1)

  [q,r]=deconv(f,g);

  if norm(r)<1e-10

    break;

  end

  while(abs(r(1))<1e-10)

      r(1)=[];

  end

  f=g;

  g=r;

end

gcd=g/g(1)

gcd =

     1.0000   2.0000