deleting an element from a Matrix without changing its dimensions?

i am working on Matlab R2008a;
to apply the EM learning for BN i need to have a matrix with some empty element in it; for example: A = [ 1 2 3 4 5 6 7 8 9] i want to delete the element '5'; the code:
A (2,2) = []; will convert A to a one raw vector ?! i want to keep it (3x3) matrix but the element (2,2) is simply empty thank you.

 Accepted Answer

variant for double array: instead of an empty element - nan
A = [ 1 2 3; 4 5 6; 7 8 9];
A(2,2) = nan;
variant for cell array:
A = num2cell([ 1 2 3; 4 5 6; 7 8 9]);
A(2,2) = {[]};

More Answers (0)

Community Treasure Hunt

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

Start Hunting!