I have to create a 2D matrix, where the row number is unknown. I will have to find the row number.

Say, for i=1:5

for j=1:3

I want to create a 2D matrix with 2 columns, where the entries will be like [i j]

How should I write the code?

Skip to content# MATLAB: Assigning a 2D matrix

###### Related Question

2d matrix

I have to create a 2D matrix, where the row number is unknown. I will have to find the row number.

Say, for i=1:5

for j=1:3

I want to create a 2D matrix with 2 columns, where the entries will be like [i j]

How should I write the code?

- How to avoid for nested loops with if condition
- How to fill matrix in a specific way
- Make a better code to check the neighbours of a cell in a matrix and replace a value
- Index Exceeds the number of array elements (993268)
- Matrix
- For Loop /Array question
- Replace matrix elements by the difference with the highest alternative in the same row
- Removing inner for loop
- Insert missing values in specified positions and use for loop

## Best Answer