# 加载中...

• 博客等级：
• 博客积分：0
• 博客访问：84,899
• 关注人气：309
• 获赠金笔：0支
• 赠出金笔：0支
• 荣誉徽章：

(2015-04-16 19:34)

### matlab

clear all;clc;close all;
%% 采样点
x=[0 :0.2:10];
y=erf(x);

%% 多项式曲线拟合
i=2;
while(1)
[p,S]=polyfit(x,y,i);
if S.normr<=0.05
break;
else
i=i+1;
end
end
p_x=polyval(p,x);

%% 绘图
plot(x,y,'ro',x,p_x,'b')
xlabel('x'),ylabel('y=sin(x)')
legend('y(x)','p(x)')
title([num2str(i),'th-degree polynomial'])
gtext(['p(x)=',poly2str(p,'

(2015-04-16 09:31)

### matlab

x=[0 :0.2:10];
y=erf(x);

(2015-04-14 13:17)

### matlab

>> A=[9 0 -4 1 0 0 2];
>> dA=polyder(A);
>> dA_str=poly2str(dA,'n')

dA_str =

54 n^5 - 16 n^3 3 n^2

>> B=[-3 1 0 -13 2];
>> int_B=polyint(B,9);
>> int_B_sym=poly2sym(int_B,'s')

int_B_sym =

- (3*s^5)/5 s^4/4 - (13*s^2)/2 2*s 9

(2015-04-14 10:03)

### matlab

(2015-04-12 20:38)

### matlab

>> p=[1 6 0 2 1 1];
>> p_2=polyval(p,2)

p_2 =

139

>> p=[1 6 0 2 1 1];
>> r=roots(p)

r =

-6.0509 0.0000i
0.3783 0.6219i
0.3783 - 0.6219i
-0.3529 0.4329i
-0.3529 - 0.4329i

>> r=[0.5 -1];
>> p=poly(r)

=

Columns through 3

1.0000   -1.5000   -1.5000

Column 4

1.0000

>> p1=[2 3 1];
>> p2=[5 0 1];
>> prod=conv(p1,p2)
prod =
10    15

(2015-04-12 11:34)

### matlab

(2015-04-09 17:48)

### matlab

clear all;clc;close all;

[X,Y,Z,V]=flow(5);
figure;
slice(X,Y,Z,V,[1 9.5],2,[-1 3]);

[Xq,Yq,Zq]=meshgrid(0.1:0.5:10,-3:0.5:3,-3:0.5:3);
Vq=interp3(X,Y,Z,V,Xq,Yq,Zq);
figure;
slice(Xq,Yq,Zq,Vq,[5 9],2,[-2 2])

(2015-04-09 08:44)

### matlab

(2015-04-07 21:56)

### matlab

clear all;clc;close all;

service 10:10:30;
years 1950:10:1990;

wage [150.697 199.592 203.625;
179.323 195.072 250.287;
203.212 200.092 322.767;
226.505 237.706 426.730
249.633 257.281 598.243];
w_16_1988 interp2(service,years,wage,16,1988)

w_16_1988 =

250.0226

(2015-04-07 16:17)