Help Needed with looping commands
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
I have two sets of column data (about 120 data points each), d(:,1) and c(:,2).
How do I use the 'for' and 'if' loop commands to evaluate the difference between each of the points in the variables (that is, say E = d - c) and then compare each of the outcome with an error value computed already to produce another column data of results less than the error benchmark.
Thank you.
댓글 수: 0
답변 (1개)
KSSV
2020년 9월 17일
Just use:
E = d(:,1)-c(:,2) ;
You need not to use a loop.
댓글 수: 4
inteli
2020년 9월 17일
KSSV
2020년 9월 17일
If A, B, C and D are arrays of same size.
E = A-B ; % get difference
idx = E<C ; % compare difference of A, B with elements in C
iwant = D(idx) ; % get elements in D by above comparison
inteli
2020년 9월 17일
KSSV
2020년 9월 17일
You can do what I have shown above right? Do the comparison, get the logical indices and pick the points.
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!