Clear Filters
Clear Filters

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

4 views (last 30 days)
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 Comments
tinkyminky93
tinkyminky93 on 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 on 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.

Sign in to comment.

Answers (1)

David Hill
David Hill on 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 Comments
Torsten
Torsten on 29 Mar 2022
Edited: Torsten on 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)].

Sign in to comment.

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!