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

3 visualizzazioni (ultimi 30 giorni)
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 Commenti
tinkyminky93
tinkyminky93 il 29 Mar 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
Torsten il 29 Mar 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.

Accedi per commentare.

Risposte (1)

David Hill
David Hill il 29 Mar 2022
Sounds like you need two matrices. A x matrix and a y matrix.
[x,y]=meshgrid(0:100:200,0:250:500);
  4 Commenti
Torsten
Torsten il 29 Mar 2022
Modificato: Torsten il 29 Mar 2022
I already gave you the answer above.
Everywhere where you would use A(i,j), you write [x(i,j),y(i,j)].
tinkyminky93
tinkyminky93 il 29 Mar 2022
I see sir, I understood. I asked one more and the last question above.

Accedi per commentare.

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by