필터 지우기
필터 지우기

How to Modify Entries in Cell

조회 수: 2 (최근 30일)
itend
itend 2017년 6월 13일
편집: James Tursa 2017년 6월 13일
Hello,
I would greatly appreciate any/all help with this issue:
I have a 18 x 1 cell array. Each cell in this array contains an (1024 x 1024 x 50 , value = double) matrix. Thus, there are a total of 18 of these matrices, each one stored in a separate cell.
I would like to modify each of the matrices by cutting out the last 2 "frames" --> producing a total of 18 (1024 x 1024 x 48) matrices, each one stored in a separate cell.
Please help! Thanks :)

채택된 답변

James Tursa
James Tursa 2017년 6월 13일
result = cellfun(@(x)x(:,:,1:end-2),your_cell_array,'uni',false);
  댓글 수: 2
itend
itend 2017년 6월 13일
편집: itend 2017년 6월 13일
Fantastic!
Many thanks :)
Quick question, what is the @(x)x doing within the context of this line of code? I can understand the rest of it.
James Tursa
James Tursa 2017년 6월 13일
편집: James Tursa 2017년 6월 13일
@(x)x(:,:,1:end-2) creates an anonymous function on the fly. It takes an input x and returns a truncated version of x with the last two pages removed. E.g.,
>> y = reshape(1:24,2,3,4)
y(:,:,1) =
1 3 5
2 4 6
y(:,:,2) =
7 9 11
8 10 12
y(:,:,3) =
13 15 17
14 16 18
y(:,:,4) =
19 21 23
20 22 24
>> f = @(x)x(:,:,1:end-2)
f =
@(x)x(:,:,1:end-2)
>> f(y)
ans(:,:,1) =
1 3 5
2 4 6
ans(:,:,2) =
7 9 11
8 10 12

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by