Clear Filters
Clear Filters

Finding The x[n^2] Graph

53 views (last 30 days)
enrique128
enrique128 on 14 Nov 2020
Commented: enrique128 on 15 Nov 2020
Hello everyone, I need to plot the graph of x[n^2]. When I enter the values like n=n^2 the stem graph has 2 values on the spesific number. For example my code is
n=[-5 -4 -3 -2 -1 0 1 2 3]
x=[1 -2 3 2 1 0 9 7 2]
when I write n=n^2 the -3 and 3, -2 and 2, -1 and 1 values are located on each other. How can I solve this problem? Thanks.

Accepted Answer

Walter Roberson
Walter Roberson on 14 Nov 2020
n=[-5 -4 -3 -2 -1 0 1 2 3];
x=[1 -2 3 2 1 0 9 7 2];
stem(x, n.^2)
This is correct output for n^2 vs x, because you have duplicate x values.
stem3(1:length(x), x, n.^2); xlabel('t'); ylabel('x'); zlabel('n^2')
  9 Comments
Walter Roberson
Walter Roberson on 15 Nov 2020
n = [-3 -2 -1 0 1 2 3 4];
x = [0 0 1 1 1 1 1/2 1/2];
y = interp1(n, x, n.^2, 'linear', 0);
stem(n, y)
enrique128
enrique128 on 15 Nov 2020
you are a hero! thanks sir.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!