How to search a table inside a cell
조회 수: 3 (최근 30일)
이전 댓글 표시
I have been given a workspace that has a cell variable that is 1x10 inside each cell is a table that is 100x16. Each column in each table has the same var names (time, rpm, temp, p1, p2, etc...).
I want to search the table in data(1,1) to find the first time what the temp is 300, but cannot figure out how.
댓글 수: 3
Adam Danz
2021년 4월 8일
Access the cell using curly brackets.
Access a column variable in a table using dot-notation.
C{i}.var
답변 (1개)
Tejas
2025년 2월 27일
Hello Jason,
To determine the time value for a specific temperature, consider these steps:
- Begin by accessing the initial table located in the cell array.
firstTable = data{1,1};
- Use the 'find' function to locate the index of the first occurrence of the target temperature value. More information on the function, can be found in this documentation: https://www.mathworks.com/help/matlab/ref/find.html .
index = find(firstTable.temp == 300, 1, 'first');
- Retrieve the time value at the identified index using the provided syntax.
timeAtTemp300 = firstTable.time(index);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Tables에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!