Subtracting two cell arrays, yielding a third cell array

Hi,
I have two cell array of vectors; each cell in both cell arrays contains a 1 by 3 vector. For example,
A={[20 20 20],[30 30 30],[40 40 40];[50 50 50],[60 60 60],[70 70 70]};
B={[1 1 1],[2 2 2],[3 3 3];[4 4 4],[5 5 5],[6 6 6]};
How can I subtract B from A? For example, I wish to find:
C={[19 19 19],[28 28 28],[37 37 37];[46 46 46],[55 55 55],[64 64 64]}
Is there a way I can do this without stepping through each cell, converting them to numeric arrays using cell2mat, and then converting them back to cells?
Thank you very much for your time.
Andrew DeYoung
Carnegie Mellon University

 채택된 답변

Matt Fig
Matt Fig 2011년 6월 4일
C = cellfun(@minus,A,B,'Un',0)

댓글 수: 3

C = cellfun(@minus,A,B,'UniformOutput',false)
is clearer.
What does the 'Un' and 0 stand for ? Thanks !
'Un' and 0 are shorthand for 'UniformOutput',false, which tells cellfun to return a cell array.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Cell Arrays에 대해 자세히 알아보기

제품

질문:

2011년 6월 4일

댓글:

2018년 3월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by