Input data, round down, loop variable

1 visualización (últimos 30 días)
GH
GH el 27 de Mayo de 2020
Comentada: GH el 27 de Mayo de 2020
Hi everyone, I have lots of data in an excel file with 59 rows and 4 colums, every row's data belong together(let's say I have 'x', 'z', 'R', 'y'). I have two problems:
a) One of the variable (let's say 'y') should be an input value by the user, then the program should find in which domain (which are the those two values from the y column in between this input takes place) then choose the lower one and use that in the equation.
b) After the matlab have chosen the proper value, the loop should use its row's data (x,y,z,R) in a 4 variable equation to get the result.

Respuesta aceptada

Tommy
Tommy el 27 de Mayo de 2020
How does this work? (I'm assuming T.y is monotonically increasing)
% example table:
x = randi(10,59,1);
y = cumsum(rand(59,1));
z = randi([10 20],59,1);
R = randi([2 3],59,1);
T = table(x, y, z, R);
% example user input:
yin = range(T.y)*rand + min(T.y);
%---------------------------------
% location of row of interest:
idx = find(yin > T.y, 1, 'last');
% row of interest:
vars = T{idx,:};
% vars is a 1x4 array containing the x, y, z, and R to use in your equation
  1 comentario
GH
GH el 27 de Mayo de 2020
Thank you very much! Exactly what I needed!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by