MATLAB: Finding diag of two cells

minimal detailsurgent

Hello,
I have two cells(a and b) each with size 1×4 and each of them contains 2×1 matrix in each of its columns. I would like to find diag([a b]) to get a 2×2 matrix but it seems that diag() is not defined for cell. Can anybody tell me what I should do?

Best Answer

Maybe
cellfun(@diag,[a b],'uni',0)