필터 지우기
필터 지우기

How to index a matrix other than using curly brackets

조회 수: 3 (최근 30일)
Scott Banks
Scott Banks 2023년 5월 4일
댓글: Matt J 2023년 5월 5일
Hi there,
I have a matrix whereby I want to shift the values of the matrix by a given amount,. The matrix that I want to shift is given below:
T1 = zeros(6,18)
T1(1,2) = 1;
T1(2,1) = 1;
T1(3,3) = 1;
T1(4,5) = 1;
T1(5,4) = 1;
T1(6,6) = 1;
I want to shift the values of 1 by 6 places in the 6 by 18 matrix. To do this I have used the circshift function in a for loop
for i = 1:2
T1x{i} = circshift(T1,[0,i*6])
end
The shifting by a factor of 6 places is fine, but I would like to know how I can index T1x other than using the curly brackets that gives a cell format. I would like to use double format. This is because it easier to sum the matrices together at a later stage of my work.
Can anyone help me please,
Best wishes,
Scott

채택된 답변

Matt J
Matt J 2023년 5월 4일
편집: Matt J 2023년 5월 4일
Why not stack the T1x{i} into a 3D array,
T1x=cat(3, T1x{:});
Indexing them would look like,
T1x(:,:,i)
and summing over i could then be done as,
sum(T1x,3)
  댓글 수: 2
Scott Banks
Scott Banks 2023년 5월 5일
이동: Matt J 2023년 5월 5일
Thanks for your help, guys
Matt J
Matt J 2023년 5월 5일
You're welcome, but please Accept-click the answer to indicate it did what you want.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by