Array operation shift values
显示 更早的评论
i have an array of A=[0 0 0 0 0 ] im sending first value "3" array become A=[3 0 0 0 0] ... then when i send next value for e.g. "5" then array should be A=[5 3 0 0 0] and then if "1" A=[ 1 5 3 0 0] . i cant identify command for this purpose
采纳的回答
更多回答(1 个)
A = zeros(1,5);
for K = [3 5 1]
A = [K, A(1:end-1)]
end
2 个评论
Ali Mukhtar
2021-3-18
Walter Roberson
2021-3-18
A = zeros(1,5);
for K = 1:5
A = [randi(9), A(1:end-1)]
end
类别
在 帮助中心 和 File Exchange 中查找有关 Operators and Elementary Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!