# How to name every row of 100*2500 matrix in MATLAB? [closed]

currently i am working with a matrix. The dimension of the matrix is 100*2500. I need to assign each row the matrix to a new variable. How i can do this?

## closed as off-topic by MBaz, Peter K.♦Nov 1 '17 at 1:56

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "General programming questions are off-topic here, but can be asked on Stack Overflow." – MBaz, Peter K.
If this question can be reworded to fit the rules in the help center, please edit the question.

You can assign each row to a vector as follows:

row1 = matrix(1,:);


That will store the whole first row of matrix in row1.

To do this "automatically", you can store all the vectors containing each row in a cell array, for example:

for k = 1:size(matrix,1) %For each row
rows{k} = matrix(k,:); %Store the k-th row in the k-th element of the cell array
end

• this will give a cell array. But i need a row matrix. thank for your help. – MM Islam Nov 1 '17 at 1:20
• What do you mean by row matrix? I'm not sure I understand what you are looking for. – Tendero Nov 1 '17 at 1:22
• sorry. what i meant was row vector. – MM Islam Nov 1 '17 at 1:31
• let me clear it. let data = ones(3,5); so i want row1= data(1,:), row2=data(2,:) and row3= data(3,:). – MM Islam Nov 1 '17 at 1:32
• @MMIslam try this code for i=1:size(matrix,1); eval(sprintf('row%d = matrix(i,:);', i)); end; However, first, this method is very very computationally inefficient. And second, this kind of question is off-topic. – AlexTP Nov 1 '17 at 8:01