Finding The x[n^2] Graph
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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
2020년 11월 14일
0 개 추천
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
enrique128
2020년 11월 15일
편집: enrique128
2020년 11월 15일
sir shouldn't it be like stem(n.^2,x) ?
and how can it be possible I mean 3 dimensional graph. It is discrete time signal, I know we have duplicate values but there should be a trick like scaling with n or something like that.
Walter Roberson
2020년 11월 15일
Why would it be stem(n.^2, x) ? the first parameter is to be the independent variable, which is traditionally labeled "x".
Any coordinate that you are doing polynomial scaling on is not an independent variable.
If you intend n.^2 to be your indepedent variable, then draw a mock-up of what you want the outcome to look like.
enrique128
2020년 11월 15일
편집: enrique128
2020년 11월 15일
sir can you look this link:
I want to do it like that not a 3 dimensional graph
and also my real signal is stem(n,x) because n is -5 -4 -3 -2 -1 0 1 2 3 that's the reason why I said n must be in the beggining of stem command.
I had to invent new x data because (-5-1)^2 -> 36 and x[36] did not exist
n=[-5 -4 -3 -2 -1 0 1 2 3];
x=[1 -2 3 2 1 0 9 7 2 -10:-1:-37];
stem(n, x((n-1).^2+1)) %the +1 is to move from 0 indexing to 1 indexing

enrique128
2020년 11월 15일
편집: enrique128
2020년 11월 15일
sir the link in the algorithm is not like that, for example assume that we have
n=[-3 -2 -1 0 1 2 3 4];
x=[0 0 1 1 1 1 1/2 1/2];
-3^2=9, there is no value at n=9 so there should be 0 in -3.
-2^2=4, there is a value at 4 which is 1/2 so there should be 1/2 in -2.
-1^2=1, there is a value at 1 which is 1 so there should be 1 in -1.
0^2=0, there is a value at 0 which is 1 so there should be 1 in 0.
1^2=1, there is a value at 0 which is 1 so there should be 1 in 1.
2^2=4, there is a value at 4 which is 1/2 so there should be 1/2 in 2.
3^2=9, there is no value at n=9 so there should be 0 in 3.
4^2=16, there is no value at n=16 so there should be 0 in 4.
so my signal become
n=-3 -> 0
n=-2 >1/2
n=-1 > 1
n=0 > 1
n=1 >1
n=2 >1/2
n=3 -> 0
n=4 -> 0
The algorithm is like that.
n = [-3 -2 -1 0 1 2 3 4];
x = [0 0 1 1 1 1 1/2 1/2];
t = n.^2;
mask = t >= 1 & t <= length(x) & fix(t) == t;
y = zeros(size(t));
y(mask) = x(t(mask));
stem(n, y)

enrique128
2020년 11월 15일
편집: enrique128
2020년 11월 15일
sir the values that i write is not the same as your graph it should be like 0 1/2 1 1 1 1/2 0 0. The time interval is true but the values are wrong
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
2020년 11월 15일
you are a hero! thanks sir.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기
제품
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
