Diff matrix in cell array

조회 수: 4 (최근 30일)
Michal Oktawiec
Michal Oktawiec 2019년 7월 1일
댓글: Michal Oktawiec 2019년 7월 2일
Hello,
I have cell array where is 2000 matrix 4000x100. I would like to subtract each cell in matrix: A(i,j)-B(i,j+1). It is possible to use diff function for this operation? I have tried to do it, but I get same errors.
Y=arrayfun(@{diff(1,1,2)},A)
I would be grateful for any information you can provide.
Best regards
  댓글 수: 2
Stephen23
Stephen23 2019년 7월 1일
What is A? What is B ? How are they related to your cell array?
It would help if you gave us a small example of the input/s and the expected output arrays.
Michal Oktawiec
Michal Oktawiec 2019년 7월 1일
example of cell array:
rys_1.png
I would like to do substract two cell in matrix: 21.9018(i,j)-20.7261(i,j+1)
example.png

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

채택된 답변

Stephen23
Stephen23 2019년 7월 2일
편집: Stephen23 2019년 7월 2일
Given one cell array A, this seems to matche your example:
F = @(m)-diff(m,1,2);
Y = cellfun(F,A,'uni',0)
  댓글 수: 3
Stephen23
Stephen23 2019년 7월 2일
편집: Stephen23 2019년 7월 2일
@Michal Oktawiec : sorry, I used arrayfun but it should have been cellfun. I corrected the answer.
Michal Oktawiec
Michal Oktawiec 2019년 7월 2일
Thank you very much for your help!

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

추가 답변 (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