Azzera filtri
Azzera filtri

Input data, round down, loop variable

1 visualizzazione (ultimi 30 giorni)
GH
GH il 27 Mag 2020
Commentato: GH il 27 Mag 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.

Risposta accettata

Tommy
Tommy il 27 Mag 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

Più risposte (0)

Categorie

Scopri di più su Environment and Settings 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