Discrete time signal defining

15 views (last 30 days)
Nurhan Aydinalp
Nurhan Aydinalp on 7 Jan 2021
Answered: Shadaab Siddiqie on 14 Apr 2021
I am trying to define a discrete time in which n = [-5:1:5] and the values of x[n] should be 1 2 3 4 5 6 5 4 3 2 1 I have the following code
syms x(n) n h(n) y(n)
n = (-5:1:5);
x(n) = [1 2 3 4 5 6 5 4 3 2 1];
plot(x(n),n)
But When I run this I get the following error:
Error using sym/subsasgn (line 963)
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments must be
symbolic variables, and function body must be sym expression.

Answers (1)

Shadaab Siddiqie
Shadaab Siddiqie on 14 Apr 2021
From my understanding you are getting an error for the above code. This is because you are assigning non symbolic variables to a symbolic variable in line :
x(n) = [1 2 3 4 5 6 5 4 3 2 1];
Please refer syms for more information.

Community Treasure Hunt

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

Start Hunting!