Error in circularshift inside for loop.

10 views (last 30 days)
methaq ali
methaq ali on 22 Sep 2018
Commented: Walter Roberson on 23 Sep 2018
Hi,
I need your help
I get this error message
In an assignment A(I) = B, the number of elements in B and I must be the same
when execute this code:
x=[2 3 4 5 6 7 8 9 1]
for i=1:6
b(i)=circshift(x,[0,i])
end
Thanks..

Answers (1)

Walter Roberson
Walter Roberson on 22 Sep 2018
circshift() like that is going to return a vector. You are trying to store the vector into the single location b(i) .
You can create rows (or columns) of a 2D array, or you can use cell arrays.
  2 Comments
methaq ali
methaq ali on 23 Sep 2018
thank you for replay, pleace can you give example.
Walter Roberson
Walter Roberson on 23 Sep 2018
x=[2 3 4 5 6 7 8 9 1]
for i=1:6
b(i, :)=circshift(x,[0,i])
end

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!