Diff matrix in cell array

4 Ansichten (letzte 30 Tage)
Michal Oktawiec
Michal Oktawiec am 1 Jul. 2019
Kommentiert: Michal Oktawiec am 2 Jul. 2019
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 Kommentare
Stephen23
Stephen23 am 1 Jul. 2019
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 am 1 Jul. 2019
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

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by