# Combining x and y arrays and converting subsequent values

10 visualizzazioni (ultimi 30 giorni)
Shah il 30 Giu 2020
Risposto: Tommy il 30 Giu 2020
I would like to combine 2 arrays (x and y coordinates on a 1920x1080 screen) and further simplify it to represent the quadrants they appear in.
when x<960 and y<540, I would just like the value in the table to say 1.
x>960 and y<540 would be quadrant 2
x>960 and y>540 would be 3
x<960 and y>540 would be 4.
Any help would be much appreciated!
##### 2 CommentiMostra NessunoNascondi Nessuno
KSSV il 30 Giu 2020
x(x<960) = 1 ;
Rest you can do like above.
Shah il 30 Giu 2020
how can i do it to be 1 only when both conditions of x and y are fulfilled, i.e x<960 and y<540?

Accedi per commentare.

### Risposte (1)

Tommy il 30 Giu 2020
Assuming x and y are formatted like the following...
[x,y] = meshgrid(1:1920,1:1080);
q = nan(size(x));
q(x<960 & y<540) = 1;
q(x>960 & y<540) = 2;
q(x>960 & y>540) = 3;
q(x<960 & y>540) = 4;
What about row 540 and column 960?
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Logical in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by