Elseif statement with large table

1 次查看(过去 30 天)
James
James 2019-8-28
评论: James 2019-8-28
I have a 4 x 197 table. The first two columns are characters (ID and name), the last two are integers (min and max).
Each ID and name are not unique but a combination of the two is unique within the table. I need to check the table according to the pair "ID & name" and assign a min and max to it, i.e. write it to a new CSV file. Instead of having 197 elseif statements, how can I make an efficient script to accomplish this?
See attached image. Any help is greatly appreciated.
sUGXE.png
  2 个评论
Luna
Luna 2019-8-28
Do you have a rule for assigning the max and min number?
James
James 2019-8-28
Yes - the min and max are specified on the same row. So if I needed the min and max for:
ID = 'L22' and name = 'JP',
the script should return:
min = 90, max = 450

请先登录,再进行评论。

回答(1 个)

darova
darova 2019-8-28
Will it work?
for i = 1:197
i1 = find(newID(i)==ID & newname(i)==name);
newmin(i) = min(i1);
newmax(i) = max(i1);
end

类别

Help CenterFile Exchange 中查找有关 Variables 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by