How to give a dynamic variable name in for loop?

6 views (last 30 days)
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 Comments
dpb
dpb on 8 Mar 2020
"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
John D'Errico on 8 Mar 2020
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.

Sign in to comment.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!