# How to simplify x and y coordinates or numbers

조회 수: 1(최근 30일)
Conner Carriere 2021년 2월 7일
댓글: Image Analyst 2021년 2월 21일
I have multiple matrix with different x and y variables
Mr2 =
217.9198 394.7466
220.3522 288.1925
226.7584 194.7277
319.1827 396.4066
320.9901 293.0322
323.9730 194.6844
423.4146 297.8831
426.0054 399.2974
424.8713 198.3911
Mg3 =
257.5755 266.5336
259.3048 360.6109
256.0792 180.9467
351.4200 263.9756
350.5972 175.4610
356.0210 365.4651
440.5966 171.9462
444.4349 264.3318
453.3330 360.0456
I need to convert these to simpler numbers, while keeping the x and y values together
Looking at Mr2;
The three lowest values in the x column would be called 1, the three middle values would be called 2, the three highest values would be called 3.
This would work the same way in the y columns also.
The issue I am having, I am not able to find a way to do this, because the order changes, I will demonstrate the output below
Mr2 =
1 3
1 2
1 1
2 3
2 2
2 1
3 2
3 3
3 1
Mg3 =
1 2
1 3
1 1
2 2
2 1
2 3
3 1
3 2
3 3
Keep in mind that the values in the origional Mr2 and Mg3 are able to be changed, so they might have the lowest values in the 80s or the hightest in the 600's
let me know any ideas you may have, I am newer to matlab, so its a bit tough

댓글을 달려면 로그인하십시오.

### 채택된 답변

Image Analyst 2021년 2월 7일
Try discretize():
Mr2 =[...
217.9198 394.7466
220.3522 288.1925
226.7584 194.7277
319.1827 396.4066
320.9901 293.0322
323.9730 194.6844
423.4146 297.8831
426.0054 399.2974
424.8713 198.3911]
Mg3 =[...
257.5755 266.5336
259.3048 360.6109
256.0792 180.9467
351.4200 263.9756
350.5972 175.4610
356.0210 365.4651
440.5966 171.9462
444.4349 264.3318
453.3330 360.0456]
Mr2 = discretize(Mr2, 3)
Mg3 = discretize(Mg3, 3)
##### 댓글 수: 2표시숨기기 이전 댓글 수: 1
Image Analyst 2021년 2월 21일
If passing in the number of levels doesn't split it up the way you like it, you can use the option where you pass in "edges" which are the dividing values between all the different levels that you'd like to use.

댓글을 달려면 로그인하십시오.

### 추가 답변(1개)

darova 2021년 2월 21일
Try meshgrid()
[x,y] = meshgrid(1:4,1:3);
[x(:) y(:)]

댓글을 달려면 로그인하십시오.

### 범주

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by