signal processing - How to use previous element in vector in Matlab? -
i'm taking digital signal processing course requires me use matlab. i'm still beginner, i'm sorry if basic don't know how google this.
i'm supposed check linearity. have couple of vectors made randn(1,100)
, i'm supposed use them check if
f{a·x1 [n]+b·x2 [n]} = a·f{x1 [n]}+b·f{x2 [n]}
when example f{x[n]} = x[n] + 2
adding vectors easy.
one of problems f{x[n]} = ¼ (x[n]+2·x[n-1]+x[n-2])
need access previous 2 elements in vector. how can this? there's 1 f{x[n]} = n·x[n]
. here need specific index of element.
edit: answers. didn't know how approach couldn't think sample code try. figured out should create shifted vectors n-1 , n-2 values , use separate index vector n*x[n] thing. approaching whole issue wrong angle. isn't elegant solution works. sorry wasting anyone's time.
it straightforward.
>> x=[1,2,3,4] >> x(2-1) ans = 1
make sure don't go beyond limit (i.e. x(0) yields error since index must start one).
Comments
Post a Comment