What are the possible invalid expressions in this equation?

1 view (last 30 days)
n = (-20:1:20)'; n0 =t>=0; n1 =t>=10 n2 =t>=20 x = n*[n0 - n1 + 10e-0.3(n-10)(n1-n2)] plot(n,x) xlabel('n'); ylabel('x(n)'); title('x [n] = n[u(n) – u(n-10)] + 10e-0.3(n-10)[u(n-10)-u(n-20)] ');

Answers (1)

dipak nigam
dipak nigam on 25 Jun 2020
Some suggestions -
1) MATLAB doesn't have e for exponentiation. You can use exp(arr) to get a vector with exponents of all elements.
2) You need to use * for scalar and matrix multiplication and ** for element-wise multiplication.
Keeping this in mind, the expression 10e-0.3(n-10)(n1-n2) should be written as 10*(exp(-0.3*(n-10)*(n1-n2)))
You may use the * operator instead of ** as per the structure and dimensions of your variables.
Other expressions will not raise any syntax errors if the dimensions of the vectors are taken care of.

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!