![how can I shift a discrete signal (in vector form) on the x axis.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/233211/how%20can%20I%20shift%20a%20discrete%20signal%20(in%20vector%20form)%20on%20the%20x%20axis.png)
how can I shift a discrete signal (in vector form) on the x axis?
2 次查看(过去 30 天)
显示 更早的评论
By having the following graph how can i write a function to simulate the shift of the hole set of values to the left or the right of the graph?
0 个评论
采纳的回答
Star Strider
2019-8-8
Add or subtract from the ‘x’ values:
x = 1:11;
y = 10:-1:0;
figure
subplot(3,1,1)
stem(x, y) % Original
xlim([-5 15])
title('Original')
subplot(3,1,2)
stem(x-3, y) % Shift Left By 3
xlim([-5 15])
title('Shift left by 3')
subplot(3,1,3)
stem(x+3, y) % Shift Right By 3
xlim([-5 15])
title('Shift right by 3')
![how can I shift a discrete signal (in vector form) on the x axis.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/233211/how%20can%20I%20shift%20a%20discrete%20signal%20(in%20vector%20form)%20on%20the%20x%20axis.png)
0 个评论
更多回答(1 个)
KALYAN ACHARJYA
2019-8-8
编辑:Voss
2024-10-30
What you are trying is unclear. Is this one? Anyways shifting the x values, you can do it multiple ways, here one way
function shift_plot()
n=input('Enter 1 for left or any other number for right ')
x_data=[1:0.5:10];
y_data=[10:-1:1];
if n==1
stem(x_data(1:10),y_data);
else
stem(x_data(end-9:end),y_data);
end
xlim([0 10]);
end
Command Window
Enter 1 for left or any other number for right 5
n =
5
>> shift_plot()
Enter 1 for left or any other number for right 1
n =
1
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/233212/image.png)
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!