Question

I have an equation: y(n) = a^x(n).

where x1(n) ={0,1,2,3}, x2(n)={1,2,3,4}, a1=a2=1, a=2.

So, How can i write MATLAB code to test the system is linear or not?

Was it helpful?

Solution

Just apply the definition.

Consider a system S, such that the output to an input signal x(n) is S( x(n) ). S is linear if and only if

  1. S( x1(n) + x2(n) ) = S( x1(n) ) + S( x2(n) ) for any inputs x1, x2 (additivity)
  2. S( b * x1(n) ) = b * S( x1(n) ) for any input x1 and any number b (homogeneity)

In your case it's clear that neither 1 nor 2 hold, so the system y(n) = S( x(n) ) is not linear.

To test it with code: randomly generate many examples of x1, x2 and b and check if the equalities above hold. Note that this way you will never be sure that the system is linear. You can only be sure it isn't, namely when you find x1, x2, b for which either 1 or 2 do not hold.

Example

>> a = 2; n = 3;
>> S = @(x) a*x.^n; %// anonymous function describing your system
>> x1 = 1:4; %// test input signal
>> x2 = 11:14; %// test input signal. Same length

>> S(x1)+S(x2)
ans =
        2664        3472        4448        5616

>> S(x1+x2)
ans =
        3456        5488        8192       11664

Since the results are different, the system does not satisfy property 1, and therefore it's not linear.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top