# Assigning the Values to 2-D Matrix which has 2 Elements in Each Point

2 visualizaciones (últimos 30 días)
tinkyminky93 el 29 de Mzo. de 2022
Comentada: Torsten el 29 de Mzo. de 2022
Hello, I am trying to assign the values to a matrix. This matrix is a 3x3 matrix but every point has 2 elements, which are the coordinates of a point, in other words x and y values.
For example I want this matrix to be in the form of:
[0 500] [100 500] [200 500]
[0 250] [100 250] [200 250]
[0 0] [100 0] [200 0]
The Y values are 0, 250, 500 and the X values are 0, 100, 200 respectively. I tried to assign values by using for loop but I could not achieve the assignment of 2nd element. Can you help me? Thank you.
##### 16 comentariosMostrar 14 comentarios más antiguosOcultar 14 comentarios más antiguos
tinkyminky93 el 29 de Mzo. de 2022
I think this is not the correct solution, complex number representation should not be used as coordinates sir. Thanks for your effort. At least I understand some concepts.
Torsten el 29 de Mzo. de 2022
I just wanted to say that - although complex numbers are in principle tuples of real numbers - they can be assigned to matrix elements. Also, rules how to add, subtract, multiply and divide such matrices are already implemented.
For your case, when you work with cell arrays - these rules are not yet available and you had to define and implement them on your own.

Iniciar sesión para comentar.

### Respuestas (1)

David Hill el 29 de Mzo. de 2022
Sounds like you need two matrices. A x matrix and a y matrix.
[x,y]=meshgrid(0:100:200,0:250:500);
##### 4 comentariosMostrar 2 comentarios más antiguosOcultar 2 comentarios más antiguos
Torsten el 29 de Mzo. de 2022
Editada: Torsten el 29 de Mzo. de 2022
Everywhere where you would use A(i,j), you write [x(i,j),y(i,j)].
tinkyminky93 el 29 de Mzo. de 2022
I see sir, I understood. I asked one more and the last question above.

Iniciar sesión para comentar.

### Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

R2021b

### Community Treasure Hunt

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

Start Hunting!

Translated by