What's the difference?

조회 수: 2 (최근 30일)
Francesco
Francesco 2014년 2월 21일
댓글: Francesco 2014년 2월 21일
out1.Y=cellfun(@(c) bsxfun(@minus, c,c(100,:)), out1.Y,'uni',0);
>> out1.Y
ans =
Columns 1 through 4
[1000x9 double] [1000x9 double] [1000x9 double] [1000x9 double]
Columns 5 through 8
[1000x9 double] [1000x9 double] [1000x9 double] [1000x9 double]
matrice1=bsxfun(@minus,matrice1, matrice1(100,:)); %%
where matrice1 is the 1000x9 double. What's the difference between this two lines of code? I think there is no difference. Is ir right? Is it the same thing? I would like to do the same thing but the line command is different because in the first code I work with cell array and in the second code I work with simply array.

채택된 답변

Walter Roberson
Walter Roberson 2014년 2월 21일
The first line goes through and does the task for all cell array members in out1.Y and the second one only does a single numeric array.
The @(c) is creating an anonymous function for cellfun to act on. You can see that the anonymous function's body is structurally the same as the second line, so the logic of the second one is being applied repeatedly in the first one.
  댓글 수: 1
Francesco
Francesco 2014년 2월 21일
Thanks!

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by