-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomework_ch8.m
More file actions
55 lines (46 loc) · 1.29 KB
/
Homework_ch8.m
File metadata and controls
55 lines (46 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
%5.29日作业
%------------------------------分界符----------------------------------%
%第一题
% x_1=1:0.1:3;
% %用五次多项式拟合后求导数
% p=polyfit(x_1,1./sqrt((x_1.^2)+1),5);
% dp=polyder(p);
% dpx=polyval(dp,x_1)
% %直接对函数求导
% dx=diff(sqrt([x_1,x_1+0.1].^2+1))/0.1
%
% gx=x_1/sqrt(x_1.^2+1)
%
% plot(x_1,dpx,'b-')
% hold on
% xx=1:0.1:3;
% yy=1./sqrt(1+xx.^2);
% plot(xx,yy)
%------------------------------分界符----------------------------------%
%第二题
q_2=integral(@(x)(sin(x)).^5.*sin(5.*x),0,pi)
%------------------------------分界符----------------------------------%
%第三题
k=1:7;
xk=0.3:0.2:1.5;
fxk=[0.3895,0.6598,0.9147,1.1611,1.3917,1.6212,1.8325];
s1=sum(fxk(1:end-1).*(diff(xk))) %这条语句的作用是???
s2=trapz(xk,fxk) %梯形积分
%------------------------------分界符----------------------------------%
%第四题
fxy=@(x,y) 1./(sqrt(x.^2+y.^2));
q_4=integral2(fxy,0,1,0,1)
%------------------------------分界符----------------------------------%
%第五题——傅里叶FFT变换
N=64; %采样点数
T=5;%采样时间终点
t=linspace(0,T,N);
x=exp(-t);
dt=t(2)-t(1);
f=1/dt;
X=fft(x);
F=X(1:N/2+1);
f=f*(0:N/2)/N;
plot(f,abs(F),'-*')
xlabel('Frequency');
ylabel('|F(k)|')