How to give a dynamic variable name in for loop?
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi everybody,
I have a 4500x3 sized matrix. First two columns of the matrix contains the x and y value of the data set and third column contains the class labels as a numeric value like 7,3,1 sizes of the classes are not same and changing accourding to the user input. I want to sort each class from this main matrix to class1,class2, classn in a for loop.
댓글 수: 2
dpb
2020년 3월 8일
"I want to sort each class from this main matrix to class1,class2, classn..."
That may be what you want to do, but it's almost certainly NOT the way to proceed.
Instead, read the data into an array and use the CLASSID variable as a grouping variable to process the data by group.
Showing a small subset of the file would help folks to see what it actually is...
John D'Errico
2020년 3월 8일
It may be what you think you want to do.
Instead, do some reading there, and recognize it may not be a good idea.
Instead, learn to use arrays of the many types available in MATLAB. Perhaps a cell array if necessary.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!