感觉还是把题号写好比较好,万一有人想参考,搜题号的时候就可以搜到吧。
(1)Problem 44948. Calculate a Damped Sinusoid
The equation of a damped sinusoid can be written as
y = A.ⅇ^(-λt)*cos(2πft)
where A, λ, and f are scalars and t is a vector.
Calculate the output sinusoid y given the inputs below:
- lambda - λ
- T - maximum value of t
- N - number of elements in t
Assume A = 1 and f = 1 . The vector t should be linearly spaced from 0 to T, with N elements.
今天的题目比较简单,就是把给出的输入数据带进到公式里就好了,主要是t时间向量并没有直接给出来,而是需要用linspace将T和N使用上。
答:
function y = damped_cos(lambda, T, N)
a = lambda;
t = linspace(0,T,N);
y = exp(-a*t).*cos(2*pi.*t);