Finding The x[n^2] Graph

52 次查看(过去 30 天)
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.

采纳的回答

Walter Roberson
Walter Roberson 2020-11-14
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 个评论
Walter Roberson
Walter Roberson 2020-11-15
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 2020-11-15
you are a hero! thanks sir.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multirate Signal Processing 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by