필터 지우기
필터 지우기

Using reshape function i get wrong ans....

조회 수: 4 (최근 30일)
ARJUN K P
ARJUN K P 2015년 5월 18일
댓글: ARJUN K P 2015년 5월 18일
b=[0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1];
>> SS=reshape(b,length(b)/8,8);
>> SS
SS =
0 0 0 0 0 0 0 0
1 0 1 0 1 0 1 0
0 0 0 0 0 0 0 0
0 1 0 1 0 1 0 1
bt i want to get
SS =
0 1 0 0 0 0 1 0
0 1 0 0 0 0 1 0
0 1 0 0 0 0 1 0
0 1 0 0 0 0 1 0
ie what my array b data.. thats i want to be in SS.. how i write code? Help me
  댓글 수: 1
Jan
Jan 2015년 5월 18일
Where does the trailing zero column come from? It is not clear why the last and teh 2nd last column seem to have swapped.

댓글을 달려면 로그인하십시오.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2015년 5월 18일
b=[0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1];
SS=reshape(b,8,[]);
SS([end,end-1],:) = SS([end-1,end],:);
SS = SS';
  댓글 수: 6
ARJUN K P
ARJUN K P 2015년 5월 18일
편집: ARJUN K P 2015년 5월 18일
sry its my mistake..
b=[0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1]; i want to group each 8 bits in array b.. that is i want my ans like
0 1 0 0 0 0 0 1
0 1 0 0 0 0 0 1
0 1 0 0 0 0 0 1
0 1 0 0 0 0 0 1
ARJUN K P
ARJUN K P 2015년 5월 18일
thanku all i got ans.... special thanks to Andrei Bobrov code is working

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by