How to simplify x and y coordinates or numbers

1 vue (au cours des 30 derniers jours)
Conner Carriere
Conner Carriere le 7 Fév 2021
Commenté : Image Analyst le 21 Fév 2021
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

Réponse acceptée

Image Analyst
Image Analyst le 7 Fév 2021
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 commentaires
Conner Carriere
Conner Carriere le 7 Fév 2021
Modifié(e) : Conner Carriere le 7 Fév 2021
This works for some of them, but it did not work for all, for example
Mo =
261.7609 293.3977
263.7386 203.8243
266.0393 382.0060
347.7693 202.2619
351.9047 286.8964
354.7944 377.7990
439.3512 196.7476
445.0149 285.3035
445.9264 377.8791
The output was
Mo = discretize(Mo,3);
Mo =
2 2
2 1
2 3
2 1
2 2
2 3
3 1
3 2
3 3
Is there any way to further refine this, as it gave me to many 2's in the x.
Overall, this did help me quite a bit, thank you @Image Analyst
Image Analyst
Image Analyst le 21 Fév 2021
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.

Connectez-vous pour commenter.

Plus de réponses (1)

darova
darova le 21 Fév 2021
Try meshgrid()
[x,y] = meshgrid(1:4,1:3);
[x(:) y(:)]

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by