哪个懂matlab的帮我解释下下面程序的意思chap1_8chap1_8diff.mclear all;close all;h=0.001;%sampling timedelta=150r1_1=0;r2_1=0;r_1=0;for k=1:1:10000 循环time(k)=k*h;r0(k)=sin(2*pi*k*h);n(k)=0.05*rands(1);r(k)=r0(k)+n(k);dr0(k)=2*
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/27 21:17:24
哪个懂matlab的帮我解释下下面程序的意思chap1_8chap1_8diff.mclear all;close all;h=0.001;%sampling timedelta=150r1_1=0;r2_1=0;r_1=0;for k=1:1:10000 循环time(k)=k*h;r0(k)=sin(2*pi*k*h);n(k)=0.05*rands(1);r(k)=r0(k)+n(k);dr0(k)=2*
哪个懂matlab的帮我解释下下面程序的意思
chap1_8
chap1_8diff.m
clear all;
close all;
h=0.001;%sampling time
delta=150
r1_1=0;r2_1=0;
r_1=0;
for k=1:1:10000 循环
time(k)=k*h;
r0(k)=sin(2*pi*k*h);
n(k)=0.05*rands(1);
r(k)=r0(k)+n(k);
dr0(k)=2*pi*cos(2*pi*k*h);
r1(k)=r1_1+h*r2_1;
x1(k)=r1_1-r(k);
x2(k)=r2_1;
r2(k)=r2_1+h*chap1_8fst(x1(k),x2(k),delta,h);
dr(k)=(r(k)-r_1)/h;%By difference
r_1=r(k);
r1_1=r1(k);
r2_1=r2(k);
end
figure(1);
subplot(211);
plot(time,r0,'k:',time,r,'k','linewidth',2);
xlabel('time(s)'),ylabel('r0,r');
legend('ideal sidnal','signal with noise');
subplot(212);
plot(time,r0,'k:',time,r1,'k','linewidth',2);
xlabel('time(s)'),ylabel('r0,r1');
legend('ideal signal','signal by TD');
figure(2);
subplot(211);
plot(time,dr0,'k:',time,dr,'k','linewidth',2);
xlabel('time(s)'),ylabel('dr0,dr');
legend('ideal derivative signal','derivative signal by difference');
subplot(212);
plot(time,dr0,'k:',time,r2,'k','linewidth',2);
xlabel('time(s)'),ylabel('dv0,r2');
legned('ideal derivative signal','derivative signal by TD');
函数文件:chap1_8fst.m
function f=chap1_8fst(x1,x2,delta,h)
d=delta*h;
d0=h*d;
y=x1+h*x2;
a0=sqrt(d^2+8*delta*abs(y));
if abs(y)>d0
a=x2+(a0-d)/2*sign(y);
else
a=x2+y/h;
end
if abs(a)>d
f=-delta*sign(a);
else
f=-delta*a/d;
end
哪个懂matlab的帮我解释下下面程序的意思chap1_8chap1_8diff.mclear all;close all;h=0.001;%sampling timedelta=150r1_1=0;r2_1=0;r_1=0;for k=1:1:10000 循环time(k)=k*h;r0(k)=sin(2*pi*k*h);n(k)=0.05*rands(1);r(k)=r0(k)+n(k);dr0(k)=2*
就是几个数组,数值通过通项循环得到,中间引用了一个函数chap1_8fst,最后画图.