split matrix into matrices with rows in same range
이전 댓글 표시
I have a matrix A as below:
a = [20 30 45 55 100; 200 150 175 60 20; 100 29 36 52 98; 28 33 48 62 95; 206 147 180 53 45];
I want to have matrices with rows in range of +/-10 and if one number of each rows are out of range, it's okay.
For example, for matrix A we can write:
B = [20 30 45 55 100; 100 29 36 52 98; 28 33 48 62 95]
C = [200 150 175 60 20; 206 147 180 53 45]
for example if I have a matrix 1000*2000 how can I split it?
댓글 수: 1
John D'Errico
2017년 3월 19일
편집: John D'Errico
2017년 3월 19일
Don't do it that way. Creating piles of separately named matrices from one is just a bad idea. It will create a mess of inefficient, buggy code. Instead, learn what a cell array is. Extract each piece into one cell of the cell array.
https://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval
As far as how to do the actual identification of what rows belong in one set or another, you need to be far more specific about your goals. A mathematical algorithm requires a specific set of clear rules. Otherwise, you will get random junk for a result.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Lengths and Angles에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!