How to assign the size of a k-th column of a cell to the k+1-th?

조회 수: 1 (최근 30일)
Flavia Lerra
Flavia Lerra 2021년 9월 29일
답변: Rik 2021년 9월 29일
Hi everybody,
I need to assign the size of the k-th column of a cell to the k+1-th in a for loop. This form seems not to work because the index exceeds the number of array elements (1).
sbc{k}=size(cycles{k+1});
  댓글 수: 5
Rik
Rik 2021년 9월 29일
And what value should the last element of sbc have?
Flavia Lerra
Flavia Lerra 2021년 9월 29일
sbc should be the size of the k+1-th column

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

답변 (1개)

Rik
Rik 2021년 9월 29일
When you execute this line:
sbc{k}=size(cycles{k+1})
the k+1 element of cycles doesn't exist yet. You will have to make sure your loop starts 1 later and does sbc{k-1}.
Alternatively you can use a second loop that runs up N-1.

카테고리

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