circshift() one number ,in each iteration?

3 ビュー (過去 30 日間)
Mary Jon
Mary Jon 2013 年 10 月 6 日
コメント済み: Image Analyst 2013 年 10 月 6 日
can I am do shifting the number A(2,1) of matrix (A) ,one times in each iteration,('iter=0' ,iter=iter+1)? how can do that?
A=[1 2 3;4 5 6;7 8 9]
% Shift A(2,1)
for k=1:size(A,2)-1
A(2,:)=circshift(A(2,:),[0 1])
end
  2 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 10 月 6 日
That's what the code is doing
Image Analyst
Image Analyst 2013 年 10 月 6 日
It shifts the entire second row one element at each iteration of the loop. Is that not what you wanted? Did you want to shift only the (2,1) element and not all of the elements in the second row? Either way, why? Seems like a funny thing to do unless it's homework or something. But it can't be homework because you would have tagged it as homework, so why do you want to do this?

サインインしてコメントする。

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 10 月 6 日
Maybe you want to save all the results
clear
A=[1 2 3;4 5 6;7 8 9]
% Shift A(2,1)
for k=1:size(A,2)-1
A(2,:)=circshift(A(2,:),[0 1])
out{k}=A
end
celldisp(out)
  6 件のコメント
Mary Jon
Mary Jon 2013 年 10 月 6 日
isnt it? that mean E(20,1) at row number 20,column number 1,
I am want shifting it (2:33),with save all the result not last result only
Image Analyst
Image Analyst 2013 年 10 月 6 日
編集済み: Image Analyst 2013 年 10 月 6 日
size(array, n) means the length of array in the nth dimension. It DOES NOT mean array(n) which is the value of the array at index n. They're totally different things. By the way, you never answered my question in the comment at the very top.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by