0
我只是试图从一个离散时间单位步骤编程一个函数,从-10到10,这样我就可以对其执行其他操作来测试一些东西,比如u [n-1],u [ 2n],u [-n]等。我在很长一段时间内没有使用过Matlab,似乎也无法使它工作。或者使用WolframAlpha更容易吗?有人会告诉我如何以任何方式做到这一点吗?Matlab中的离散时间图吗?
我只是试图从一个离散时间单位步骤编程一个函数,从-10到10,这样我就可以对其执行其他操作来测试一些东西,比如u [n-1],u [ 2n],u [-n]等。我在很长一段时间内没有使用过Matlab,似乎也无法使它工作。或者使用WolframAlpha更容易吗?有人会告诉我如何以任何方式做到这一点吗?Matlab中的离散时间图吗?
t=-10:10;
stepFCT=zeros(1,length(t));
%%%%%%u[n-1]%%%%%%
for i=1:length(t);
if t(i)-1>=0
stepFCT(i)=1;
else
end
end
figure(1)
stem(t,stepFCT)
%%%%%%u[2n]%%%%%%
stepFCT=zeros(1,length(t));
for i=1:length(t);
if 2*t(i)>=0
stepFCT(i)=1;
else
end
end
figure(2)
stem(t,stepFCT)
%%%%%%u[-n]%%%%%%
stepFCT=zeros(1,length(t));
for i=1:length(t);
if -t(i)>=0
stepFCT(i)=1;
else
end
end
figure(3)
stem(t,stepFCT)
请试试这些代码。
['stairs stairs'](http://www.mathworks.com/help/matlab/ref/stairs.html)? – thewaywewalk
0在t <0和1在t> = 1的整数值和0在其他地方 – Austin