MATLAB: How to set just RowNames in a Matrix

rownames

Hello, Let's assume I got a matrix 3×3
A = [1,2,3;4,5,6;7,8,9];
A.Properties.RowNames = {'row1','row2','row3'};
I got an error Field Assignment to a non-structure array object.
I just wanted to place names in rows and not to create a table. I want to keep as a double if possible.

Best Answer

Since you do not want to use table, which is really smart to use, I would suggest you to use cell array.
A=mat2cell(A,ones(1,size(A,1)),ones(1,size(A,2)));
A(:,2:end+1)=A(:,1:end);
A(:,1)={'row1','row2','row3'};
and it is easy to reach numeric content of the cell by typing
Anum=cell2mat(A(:,2:end))