Clean data and extraction
이전 댓글 표시
Dear expert-
I am trying to fill a column and extract some specific rows from a data, I cannot figure out how to do it.
What I want to do is:
1) If row from column H = 0, replace 0 with its corresponding row value from column G.
2) If column G = column S, extract only that row + row before and row after.
Your will be very appriciated.
Thank you
댓글 수: 4
Dyuman Joshi
2023년 10월 22일
편집: Dyuman Joshi
2023년 10월 22일
Use logical indexing for the first part - Find Array Elements That Meet a Condition, Access Data in Tables
(For the 2nd part) It's not clear to me what extract means in this context. Though the approach is similar, compare and get the indices satisfying the comparison via find and get the corresponding indices for the rows before and after by adding and subtracting 1. You will need to check if the indices are within the range of dimensions or not.
Use the indices to extract the data as required.
Sanley Guerrier
2023년 10월 22일
이동: Dyuman Joshi
2023년 10월 22일
Dyuman Joshi
2023년 10월 22일
Yes, I understood that and provided suggestions accordingly.
I specified a flow chart to go through what you want to do, whereas @Voss was kind enough to provide you a full working solution.
Sanley Guerrier
2023년 10월 22일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!