I want to use circshift until a certain value in my vector until it reaches the end of the array.

1 view (last 30 days)
I have the following vector
front_pos = 17800;
rear_pos = 58400;
B = [0 0 0 0 rear_pos 0 front_pos 0 0 0 0 0 0 0 0 0 0 0 0 0 0]';
I want to continue to circularly shift the until the front_pos variable reaches the last element in the vector

Answers (1)

KALYAN ACHARJYA
KALYAN ACHARJYA on 15 Mar 2021
Edited: KALYAN ACHARJYA on 15 Mar 2021
front_pos = 17800;
rear_pos = 58400;
B = [0 0 0 0 rear_pos 0 front_pos 0 0 0 0 0 0 0 0 0 0 0 0 0 0]';
while B(end)~=front_pos
B=circshift(B,1)
end
B

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!