Input data, round down, loop variable

1 次查看(过去 30 天)
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.

采纳的回答

Tommy
Tommy 2020-5-27
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by