problem in dealing Cell and array

조회 수: 1(최근 30일)
Vinay Killamsetty
Vinay Killamsetty 2019년 10월 20일
댓글: Vinay Killamsetty 2019년 10월 22일
I have a cell name 'k'
Each cell of 'k' contains two dimensional array with row size 'r' and column size 'q' (r*q)
I want to make a matrix whose size is (row, column)=(k*q) in which each element is a sum of elemnts of the column vector of each array in cell 'k'
I have attached the picture related to this problem for clear understanding of the problem
I there any simple solution for doing this using cellfun command

채택된 답변

Stephan 2019년 10월 20일
% produce some data to play with
r = 3;
q = 4;
k(1:5) = {rand(r,q)}; % size of k = 1 x 5
% This should do what you expect:
k = reshape(cell2mat(cellfun(@sum,k,'UniformOutput',false)),size(k,2),[])
  댓글 수: 1
Vinay Killamsetty
Vinay Killamsetty 2019년 10월 22일
Thanq very much

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

추가 답변(0개)




Community Treasure Hunt

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

Start Hunting!

Translated by