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 日

0 投票

Given one cell array A, this seems to matche your example:
F = @(m)-diff(m,1,2);
Y = cellfun(F,A,'uni',0)

3 件のコメント

Michal Oktawiec
Michal Oktawiec 2019 年 7 月 2 日
Thank you very much for your answer. Coul you tell me why I get same error when I have run this code? I get a masege:
>> F = @(m)-diff(m,1,2 );
>> Y = arrayfun(F,G,'uni',0)
Undefined function 'diff' for input arguments of type 'cell'.
Error in @(m)-diff(m,1,2)
I would be grateful for any information you can provide.
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 件)

カテゴリ

ヘルプ センター および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by