MATLAB: Adding data from one cell array to a matrix

cell arrays

M is a 2x4matrix
H is a 3x4cell array
How do i add the 1st row of H to every row of M?
M = [
1 2 3 4
5 6 7 8
];
H = {[15 35] [10 20] [30 40 10] [15]
[30 20 15] [45 55] [50 70] [30 70]
[25] [10 20 30] [25 35] [60 70]};
fun = @(m,h) [fliplr(h)+m,m,m+h];
ans=cellfun(fun,num2cell(M), *H{1,:}*,'Uni',0); < what do i put H as?
ans={[36 16 1 16 36] [20 12 2 12 22] [13 43 33 3 33 43 13] [19 4 19]
[40 20 5 20 40] [26 16 6 16 26] [17 47 37 7 37 47 17] [23 8 23]}

Best Answer

If M has two rows then
H([1,1],:)
In general
H(ones(1,size(M,1)),:)
or
repmat(H(1,:),size(M,1),1)