MATLAB: How to write the matrix with blank element

matrix with element blank

for i=1:10
if i~=6 T(i)=2*i
else T(i)= %(i want to leave it blank) end end
T
Is this possible in Matlab? If yes, How to do this?

Best Answer

Just set those elements to nan:
T(i) = nan;
otherwise you'd be looking at a cell array and that's a lot more complicated to use and you probably don't want the hassles of dealing with those. Nan means "Not a number" and is basically the concept of "not defined' that you're trying to achieve. They just call it nan instead of ND.