Adding three cells element wise using cellfun
조회 수: 6 (최근 30일)
이전 댓글 표시
Folks,
I have three cell arrays of the form 1*6 each containing an 18*9 double. I have attempted to add each corresponding element in each cell array. Ie the ith element of cell A + ith element of cell B + the ith element of cell C.
D = cellfun(@(x,y,z){x+y+z},A{ii},B{ii}, C{ii});
but i get an error stating
??? Error using ==> cellfun Input #2 expected to be a cell array, was double instead.
Any suggestions? B
댓글 수: 2
답변 (3개)
Azzi Abdelmalek
2013년 10월 23일
편집: Azzi Abdelmalek
2013년 10월 23일
n=2;
A{n}+B{n}+C{n}
Is it what you are asking for?
% or maybe you want this
ii=5
out=cellfun(@(x,y,z) x(ii)+y(ii)+z(ii),A,B,C)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!