Decision Based on Multiple Values

Dear All
I have sensor measurement data arranged in the format shown below:
The first three values in each row represents the sensing pair and the last value (highlighted in yellow) shows the position of the object in the sensing area. The decision of the position can only be made by considering the first 3 values. 1 1 1 is the minimum value and 8 8 8 is the maximum value and there are lots of combinations as shown in the figure. If I use simple if else statement I have to use a lot of them which to be honest is not a good approach.
My question is if there is a way to do this smartly without using a lots of if and else?
Thank you

4 comentarios

Walter Roberson
Walter Roberson el 7 de Dic. de 2020
6 5 4 leads to two different outcomes
M Sattar
M Sattar el 7 de Dic. de 2020
Editada: M Sattar el 7 de Dic. de 2020
Dear Mr Walter
Thankk you for the comment. Indeed they show different outcomes. The arragnment of the values have impact on the position for example 654 shows it to be at position 2 whereas 546 tells us that it lies in position 3.
line 5 compared to line 8
6 5 4 2 line 5
6 5 4 4 line 8
M Sattar
M Sattar el 7 de Dic. de 2020
I am sorry this is a mistake

Iniciar sesión para comentar.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 7 de Dic. de 2020
Editada: Walter Roberson el 7 de Dic. de 2020

1 voto

Decision trees can construct an appropriate output structure from data

Más respuestas (1)

Harry Laing
Harry Laing el 7 de Dic. de 2020
Unless there is some mathematical formula that you use to determine the position (which we don't know), then I'm afraid a long list of is/else statements seems likely.
Alternatively, you could create a 'master' reference array, that contains all the exisiting combinations and the resulting position, and then just compare the sensor data to determine the resulting positon.
E.g:
% Assuming you have an array of all sensor values / positons called MASTER_array
% Assuming your sensor data is called SENSOR_data
[NumRows_data,NumCols_data] = size(SENSOR_data);
[NumRows_master,NumCols_master] = size(MASTER_array);
object_position = NaN(NumRows_data,1); % Initialise 'position' vector for each row in sensor data
for i = 1:NumRows_data
for j = 1:NumRows_master
% test to compare each row of master array with current sensor array
if MASTER_array(j,1:3)==SENSOR_data(i,1:3)
% if sensor matches master, use 4th col in master for position
object_position(i)=MASTER_array(j,4);
end
end
end

Categorías

Productos

Versión

R2020b

Preguntada:

el 7 de Dic. de 2020

Editada:

el 7 de Dic. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by