Creating a new table from values in a table that meet a condition

조회 수: 3 (최근 30일)
Hello,
I currently have a table with different variables. I would like to create a new table from the values in which meet a condition.
For example, there is a table of test scores from a set of students and I want to create a new table with student name and score displayed of those students that scored above a certain mark and discards those that scored below.
How would I go about doing this?
Thanks for your help

채택된 답변

Cris LaPierre
Cris LaPierre 2021년 3월 9일
Logical indexing. See Ch 12 of MATLAB Onramp.
If you are actually working with a table and not a matrix, you may find this page helpful as well. The first column indicates what the output datatype will be.
  댓글 수: 2
Josh Beaumont
Josh Beaumont 2021년 3월 10일
Hello,
Thank you for your answer. Is there a way that other columns are kept as well in table form? I have managed to eliminate any data that does not meet the condition but have created an array that has removed all other columns of data. For example, I now have the scores that meet a condition but do not have any data about those scores (names etc)
Thanks for your help
Cris LaPierre
Cris LaPierre 2021년 3월 10일
Of course, but how are you doing your filtering?
I would suggest creating an index for the values you want to keep, then use the linked page to create a table that is a subset of the original table. My answer here may help. It this situation, the data was filtered to only keep a specific time each day.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Downloads에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by