vector Shift
92 次查看(过去 30 天)
显示 更早的评论
Hello guys, it there any direct command to shift vector cells for example A=[1 2 3 4 5] to be A=[0 0 1 2 3] what I am doing now is B = circshift(A,[1 2]); B[1:2]= zeros Any Comments ?
0 个评论
回答(1 个)
Paulo Silva
2011-9-12
A=[1 2 3 4 5]
B=zeros(size(A));
n=2; %Shift units
B(n+1:end)=A(1:end-n)
2 个评论
Oleg Komarov
2011-9-12
We thought the same you typed faster :).
Alternatively:
A = [zeros(n,1), A(1:end-n)]
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!